M. Reza Nasirloo
M. Reza Nasirloo

Reputation: 16614

Mount remote machine directory to its container with docker-machine on windows

When I try to mount a remote directory to a container:

$ eval $(docker-machine env manager)
$ docker run --restart=unless-stopped -d -p 3376:2375 \
-v /etc/docker:/certs:ro \
swarm manage --tlsverify \
--tlscacert=/certs/ca.pem \
--tlscert=/certs/server.pem \
--tlskey=/certs/server-key.pem \
consul://$(docker-machine ip keystore):8500

I get the error:

C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Invalid bind mount spec "C:\\Users\\MY_USERNAME\\AppData\\Local\\Programs\\Git\\etc\\docker;C:\\Users\\MY_USERNAME\\AppData\\Local\\Programs\\Git\\certs;ro": invalid mode: \Users\MY_USERNAME\AppData\Local\Programs\Git\certs;ro.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

Looks like docker-machine is trying to mount the localhost directory to the remote container but it is not what I wanted.

The workaround is to ssh into the the manager machine and run the command in there! So what is the whole purpose of docker-machine?

Am I missing something? How can I mount the remote machine directory to its container with docker-machine?

Note: I'm not using virtualbox, the machine has been created with azure driver.

Upvotes: 2

Views: 719

Answers (2)

nathanleclaire
nathanleclaire

Reputation: 1180

If using Git for Windows, you can disable this automatic path translation behavior by setting environment variable MSYS_NO_PATHCONV=1.

Upvotes: 2

friism
friism

Reputation: 19279

I'm guessing that you're using a mingw based shell, eg. Cygwin, Git Bash or similar. That shell will attempt to expand Unix-looking paths to Windows equivalents.

I recommend using a different shell (like Powershell)

Upvotes: 1

Related Questions