Docker Volume not mounting any files
Docker & Virtualbox seem to have an issue with mounting a volume outside of the /Users directory. The only way to fix the issue is to delete the docker machine image, properly set the /Users/yourname directory as the share folder in Virtualbox and create a new docker machine image.
Steps to fix the issue:
docker-machine stop dev
docker-machine rm dev
docker-machine create --driver virtualbox dev
eval "$(docker-machine env dev)"
docker build -t davesrepo/dynamo -f ./Dockerfile .
docker run -v $(pwd):/var/dynamo -d -t -p 8001:8001 --env-file ./dynamo.env --name dynamo davesrepo/dynamo
docker exec -it dynamo /bin/bash
ls
root@42f9e47fa2de:/var/dynamo# ls
Dockerfile README.md __init__.py __pycache__ bin config.ini requirements.txt seed.sql tests
Files!
Container volume not mounting to local path
You mount to /var/lib/data
but write to /var/lib
so the path you write to is not at or below the mounted path.
The easiest way to fix it is probably to change your code so you write to /var/lib/data
like this
with open("/var/lib/data/TestingVolume.txt", "r") as outFile:
data = outFile.read()
with open("/var/lib/data/TestingVolume.txt", "w") as outFile:
outFile.write("Hi, Hello")
Docker - Volume not mounting latest files in container
If you're not using fig
to start the container, the volumes
line in your fig.yml
isn't doing anything useful. If you need an interactive shell, fig
is not really the tool for you.
Just docker build
your image like normal, and then use the -v
flag to docker run
to mount the volume:
docker run -it -v <hostpath>:<containerpath> <imageid>
Related Topics
Counter Increment in Bash Loop Not Working
How to Use Gdb to Debug a Running Process
Why Doesn't "Total" from Ls -L Add Up to Total File Sizes Listed
Are There Standards for Linux Command Line Switches and Arguments
Best Way to Find Os Name and Version in Unix/Linux Platform
Is /Usr/Local/Lib Searched for Shared Libraries
Run Script with Rc.Local: Script Works, But Not at Boot
How to Get the Name of the Current Git Branch into a Variable in a Shell Script
Using 'Date' Command to Get Previous, Current and Next Month
Find a Pattern in Files and Rename Them
Where Are Include Files Stored - Ubuntu Linux, Gcc
How to Create a Configure Script
Difference Between Posix Aio and Libaio on Linux
Single File Volume Mounted as Directory in Docker
When to Check for Eintr and Repeat the Function Call
Find All Files with Name Containing String
Delete All Files Older Than 30 Days, Based on File Name as Date