How to share volumes and/or drives using docker-machine on Windows (not beta)?

Hi, I am running docker using docker-machine via VirtualBox on Windows.

When using the -v command the volume gets mounted, but docker container does not see the content of the Windows drive and likewise, if you create a file/directory in the mounted volume, you don’t see the changes back in Windows.

https://docs.docker.com/docker-for-windows/#docker-settings suggests that sharing a drive is required using the Docker Beta machinery - something I am unable to install on my machine.

Any other ways of successfully establishing a bi-directional link to a Windows volume using docker-machine?

1 Like

Well, I have solved the pickle myself.

/c/Users (lowercase c, uppercase U) is the solution

2 Likes

Can you add a few points why it solved the problem ? Is it because ‘c’ is already mounted in boot2docker?

Open settings of your docker-machine VM in VirtualBox. Go to Shared Folders section. You will most likely find that c/Users (case-sensitive) is mapped to c:\Users.

For VirtualBox shared folders to work with docker volumes, use the following commands (replace <full_project_path> with the real absolute path for the project):

docker-machine stop

vboxmanage sharedfolder add default --name "project_name" --hostpath "<full_project_path>" --automount

docker-machine start  

Then I prefer to use compose file and specify the source folder as "/project_name" like this:

volumes:
  - /project_name:/some/dir/in/container/project_name
5 Likes

This was extremely useful and surprisingly hard to find.

@senyor you’re a star, that’s exactly what I needed!!!

@senyor THX! Was about 6 hours of research and finaly here is the solution.

Does anybody know where the ./ path is located in docker toolbox virtual machine (boot2docker)?

i think so it would be possible to set up the docker-compose.yml file for both enviroments. standalone and docker toolbox.

I had similar problem. The culprit is spelling users with small “u”…it must be capital “U” Users solved the problem. I was using docker-compose to mount that volume.
volumes:
- …/…/Users/mypc/dockervolume:/var/www/html

OR
You can use full path as follows

volumes:
- /c/Users/mypc/dockervolume:/var/www/html

The culprit is how you spelled ‘users’ directory.