27

What's the difference between these two docker run commands and why one is working and the other does not.

Working Command

docker run --publish=7474:7474 --volume=$HOME/neo4j_test/data:/data neo4j

Not Working

docker run --publish=7474:7474 --volume=C:/Users/USERNAME/neo4j_test/data:/data neoj

docker run --publish=7474:7474 --volume=C:\Users\USERNAME\neo4j_test\data:/data neo4j

Error for these commands

C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Invalid bind mount spec "C:UsersUSERNAMEneo4j_testdata:/data": invalid mode: /data. See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

In the non-working commands, I just replaced $HOME with the absolute path for my user profile folder C:/Users/USERNAME

UPDATE

I did inspect the value for $HOME by executing echo $HOME on Windows Powershell. And it is in fact C:\Users\USERNAME. I also did look at the link that @Titouan Freville has commented. So I used the command

docker run --publish=7474:7474 --volume=/c/Users/USERNAME/neo4j_test/data:/data neo4j

isntead of

docker run --publish=7474:7474 --volume=C:/Users/USERNAME/neo4j_test/data:/data neoj

and it is working now. Right now I'm just wondering where the transformation of $HOME from C:\Users\USERNAME to /c/Users/USERNAME happens

4
  • 1
    Could you provide us with the error message ? You should have one. If it is a not found file, make sure that $HOME == C:/Users/USERNAME also you should look at this post : stackoverflow.com/questions/33312662/…. It could be an answer. Commented Oct 24, 2016 at 8:42
  • @TitouanFreville please see update :) Commented Oct 24, 2016 at 9:05
  • try --volume=C:\/Users\/USERNAME/\neo4j_test/\data:/data Commented Oct 24, 2016 at 9:05
  • guess it is the way Docker Machine is interpreting the path. He should transform it to a linux like version compatible with him ;) Commented Oct 24, 2016 at 9:10

2 Answers 2

33

For anyone still having this problem with Docker-for-Windows, here are the 2 solutions that work:

Prefix your command

with MSYS_NO_PATHCONV=1

In full: MSYS_NO_PATHCONV=1 docker run -v /c/path:/path

Use double-slashes

// at the beginning

In full: docker run -v //c/path:/path


Source: https://github.com/moby/moby/issues/24029#issuecomment-250412919

Sign up to request clarification or add additional context in comments.

Comments

10

To close the subject. Here is the solution ;) docker toolbox mount file on windows

Also, the interpolation of $HOME by docker on windows have to be compatible with it, so it should transform it by himself when you call it in docker command.

3 Comments

Just an additional note to this answer. The drive letter should be in lower case. For instance this will work /c/Users/USERNAME and this will not /C/Users/USERNAME
If using git-bash on windows add an extra slash, ie: -v /c/path:/path to -v //c/path:/path
Or in case of the docker tutorial: docker run -dp 3000:3000 -w //c/path/to-docker-tutorial/getting-started/app -v "$(pwd):/app" node:12-alpine sh -c "yarn install && yarn run dev" - so, also the extra slash for the working directory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.