I am using Docker Toolbox in Windows and am trying to mount a Windows folder in a docker-compose.yml file like this:
nginx:
image: nginx:latest
container_name: test_server
ports:
- "80:80"
volumes:
- /sss:/c/data/www:ro
environment:
- VIRTUAL_HOST=test.local
My objective is to mount C:\data\www
to the boot2docker VM image which is already created by Docker Toolbox and then from there to the nginx container inside of it.
Unfortunately it's not working. I get a folder sss inside the boot2docker image, but it's empty without targeting to my Windows data.
What am I doing wrong? Is there a better practice in order to use Docker on Windows while you are developing (so you need to share code between Windows, the Docker VM (boot2docker) and Docker containers)?
My objective is to Mount
C:\data\www
to boot2docker VM image
From "Manually sharing directory as docker volume mounting point":
You need to:
modify your VirtualBox VM (make sure it is stopped first):
VBoxManage sharedfolder add <machine name/id> --name <mount_name> --hostpath <host_dir> --automount
# in your case
/c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe sharedfolder add default --name www --hostpath 'C:\data\ww' --automount
add an automount to your boot2docker VM:
root
) /mnt/sda1/var/lib/boot2docker/bootlocal.sh
, (sda1
may be different for you)Add
mkdir -p <local_dir>
mount -t vboxsf -o defaults,uid=`id -u docker`,gid=`id -g docker` <mount_name> <local_dir
(you might have to add the umask
as in here)