Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using absolute path with docker run command not working

Tags:

docker

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

like image 363
jmc Avatar asked Oct 24 '16 08:10

jmc


2 Answers

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

like image 129
AdrienW Avatar answered Oct 02 '22 21:10

AdrienW


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.

like image 20
Titouan Freville Avatar answered Oct 02 '22 23:10

Titouan Freville