moby: Basic volume mount fails with windows docker client against boot2docker
I’m just trying to do the most basic volume mount. Something like…
$ docker run -it -v /myvol debian:jessie /bin/bash
FATA[0000] Error response from daemon: cannot bind mount volume: C volume paths must be absolute.
Using docker 1.6 Windows Client / Boot2Docker Host Git Bash with eval ${boot2docker shellinit}
Using a host directory I get…
$ docker run -it -v /myvol:/myvol debian:jessie /bin/bash
invalid value "C:\\Program Files (x86)\\Git\\myvol;C:\\Program Files (x86)\\Git\\myvol" for flag -v: \Program Files (x86)\Git\myvol;C:\Program Files (x86)\Git\myvol is not an absolute path
See 'c:\Program Files\Boot2Docker for Windows\docker.exe run --help'.
I expected everything to run relative to the host. e.g. I expected the same behavior as if I was running these commands with boot2docker ssh
. Am I missing something here?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 22 (6 by maintainers)
Commits related to this issue
- Add workaround in docs for git bash usage issue When using boot2docker through git bash, the is a nasty issue when trying to share a folder, due to how git bash parses the URIs. The issue is explaine... — committed to mlarcher/docker by mlarcher 9 years ago
- Add workaround in docs for git bash usage issue When using boot2docker through git bash, there is a nasty issue when trying to share a folder, due to how git bash parses the URIs. The issue is explai... — committed to mlarcher/docker by mlarcher 9 years ago
- Add workaround in docs for git bash usage issue When using boot2docker through git bash, there is a nasty issue when trying to share a folder, due to how git bash parses the URIs. The issue is explai... — committed to moxiegirl/docker by mlarcher 9 years ago
- Add workaround in docs for git bash usage issue When using boot2docker through git bash, there is a nasty issue when trying to share a folder, due to how git bash parses the URIs. The issue is explai... — committed to calavera/docker by mlarcher 9 years ago
- Add workaround in docs for git bash usage issue When using boot2docker through git bash, there is a nasty issue when trying to share a folder, due to how git bash parses the URIs. The issue is explai... — committed to tiborvass/docker by mlarcher 9 years ago
- Updated README files to remove escaping from command line (https://github.com/moby/moby/issues/12751, `MSYS_NO_PATHCONV=1`). — committed to mabrarov/build-scripts by mabrarov 7 years ago
By default, only the "c:\users" directory is shared with the VirtualBox VM, so anything outside of that can’t be used as a volume, unless you configured VirtualBox to share other directories
@adeelahmadch I found Docker-compose has an option
COMPOSE_CONVERT_WINDOWS_PATHS
which solves this problem:You can also set an environmental variable to disable path conversion, but note this was ONLY added in Git for Windows.
MSYS_NO_PATHCONV=1 docker run -v ...
It’s still a very hacky fix.
http://stackoverflow.com/a/34386471/1160528
Just like in actual Linux, G4W’s shell (called mintty) supports
.bashrc
files - so you can create one (touch ~/.bashrc
orvim ~/.bashrc
) and addexport MSYS_NO_PATH=1
.After that, relaunch your bash and it’ll warn you that login scripts are missing, but have been automatically added - and never worry about this again (until it’s properly dealt with, at least).
Personally I found that automatic path conversion caused nothing but problems, which is why I’ve blanket disabled it (in gitbash/mintty). If you find yourself needing it occasionally, just drop a
MSYS_NO_PATHCONV=0
infront of the command you need - or, even runexport MSYS_NO_PATHCONV=0
to enable it for that session.A better way to convert paths is to do it explicitly, with
cygpath -m /c/cygwin/unixy/path
converts toC:/cygwin/unixy/path
.I tried the path workarounds with limited luck but indeed this is MSYS path conversion in action – a few more details here
Double slash works if desperate – e.g. these work
but for now probably best to use either powershell or boot2docker ssh
docker run -d --name redis-server -p 6379:6379 -v /h/redis:/var/lib/redis anapsix/redis
/h/redis = H://redis
@skaegi @SirRagnar This is duplicate of #12590. It’s happening due to msys, it converts unix paths to windows paths before passing them to docker.exe. In this case, that’s not a docker bug. (it’s not a msys bug either, it’s by design.)
See my comments in #12590 to run it correctly, or use cmd.exe or powershell to not to have this problem.
Or when I try to create a container like this,
docker run -v $(pwd):/app -w /app node npm start
I get “:/app” is not a valid repository/tag: invalid reference format.So I’m not sure what I’m doing wrong to get this to work. I’ve already got an express app installed and I’m in that directory, that’s where the PWD comes in and seems to throw no error. Only the
:/app
Just to update,
docker run -w C:/Users/djackson/ExpressSite node npm start
Just trying to get something to work but the above tells me
Error response from daemon... It needs to be an absolute path
and I thought that was an absolute path… This is driving me nuts! Lol.Error: Invalid volume specification Info: Docker 1.12.5 docker-compose version 1.9.0 docker-machine.exe version 0.8.2 Terminal: git bash OS: Windows 10
Description: I just want to share my experience here for windows users who use git bash and ran into volume mount issue. i had a similar problem but unlike other people i was facing issue with “docker-compose up” command. In my .yml file i was trying to mount volume like;
i tried everything from // to ’ but nothing worked for me. at the end i tried this workaround to make it work.
So when you don’t specify volume it use the same name as of your source directory and it worked. now i can see my folder mounted under /files on my docker container.
😃
The double slash at the beginning works in most cases. But there’s one in particular that won’t work
Problem bit is
--exclude='/vendor'
if I switch it to--exclude='//vendor'
rsync doesn’t match it properly so the vendor directory is included. If I change it to--exclude='vendor'
it excludes in sub dirs as well.I’ve tried playing with the posix path conversion rules that @skaegi linked to, but couldn’t find a combo that would work. Any suggestions?
@ahmetalpbalkan do you think we should add something to the docs explaining this? I can imagine more people will run into this.
I’m going to close this issue, because of the reasons mentioned above https://github.com/docker/docker/issues/12751#issuecomment-96288101
Thanks for reporting @skaegi, it’s appreciated