Docker: Mount volume from Windows host

2019-09-15 17:14发布

问题:

I use 1.12 version of Docker on Windows, since I can't use the Hyper-V feature with the newer "native" version - so I have my quickstart terminal and communicate to docker host via the invisible underlying virtual box.

Now I have the problem, that I need to mount a local folder to a container, which worked successfully from within the docker-machine by adding

--volume="`pwd`:/root/data"

to the docker run command, but it does not when I launch the same command from my Windows quickstart terminal (even though pwd command works correctly in the terminal).

I tried to find the Windows specific settings for the directory and tested several combinations of format, but no luck. Can anyone help me out on how to correctly specify a Windows folder (e.g. C:\Users\alexander.ruehl) for the volume parameter?

回答1:

You can use relative path for your volume : --volume="./mydata:/root/data"

Also make sure that you have given the permission for read/write to Docker.