Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'docker run -v' does not work on Windows using Docker Toolbox

When running the following command from a CoreOS VM, it works as expected:

docker run --rm -v $PWD:/data composer init

It will initialize the composer.json file in the current working directory by using the Docker volume mapping as specified. The Docker container basically has the PHP tool composer installed and will run that tool inside the /data folder of the container. By using the mapping it actually applies it on the files on the host machine.

However when trying to run this command on Windows using Docker Toolbox I get the following error.

$ docker run --rm -v $PWD:/data composer --help
invalid value "C:\\Users\\Marco;C:\\Program Files\\Git\\data" for flag -v: bad mount mode specified : \Program Files\Git\data
See 'C:\ProgramData\Chocolatey\lib\docker\bin\docker.exe run --help'.

What I notice here is although I am in Git Bash when executing the command it still uses Windows paths. So then I tried following (surround with quotes):

$ "docker run --rm -v $PWD:/data composer --help"
bash: docker run --rm -v /c/Users/Marco:/data composer --help: No such file or directory

Now it is unable to find the directory.

I also tried without the $PWD variable, but this doesn't make a difference.

How do I make this work on Windows?

like image 219
Marco Avatar asked Nov 06 '15 12:11

Marco


1 Answers

This should work: $ docker run --rm -v //c/Users/Marco:/data composer --help

like image 168
Andre Kreienbring Avatar answered Sep 20 '22 03:09

Andre Kreienbring