Reputation: 1829
I'm trying to go through the Docker Tutorial and mount a volume to my host OS, as in
$ sudo docker run -d -P --name web -v /src/webapp:/opt/webapp training/webapp python app.py
I'm trying to mount a directory from my host OS (OSX) to the VM:
$ docker run -P --name web -v /Users/simon/source/test:/opt/test training/webapp ls -al /opt/test
total 4
drwxr-xr-x 2 root root 40 Jun 27 17:48 .
drwxr-xr-x 5 root root 4096 Jun 27 17:51 ..
$
But from the host OS:
$ ls -al /Users/simon/source/test
total 0
drwxr-xr-x 3 simon staff 102 Jun 27 10:55 .
drwxr-xr-x@ 36 simon staff 1224 Jun 27 10:55 ..
-rw-r--r-- 1 simon staff 0 Jun 27 10:55 foo
$
Perhaps related - my understanding is that docker volumes are supposed to be stored in /var/lib/docker
, which doesn't exist for me:
$ ls -al /var/lib/docker
ls: /var/lib/docker: No such file or directory
Upvotes: 2
Views: 3046
Reputation: 121642
Docker server does not work on darwin. That's why you use the VM. When you use -v
, you actually send the command to the docker server running on the vm. The path you send or relative to the server, not the client. /var/lib/docker
is present on the VM, not the host. The empty volume you see is the expected behavior as it mounts /Users/simon/source/test
from the VM which does not exists, therefor gets created by docker and is empty.
In order to achieve what you are trying to do, either move to the VM or setup shared directories or even better, do not use bind-mounts. See Dockerfile's ADD
as an alternative.
Upvotes: 4