Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic volume mount fails with windows docker client against boot2docker #12751

Closed
skaegi opened this issue Apr 24, 2015 · 22 comments
Closed

Basic volume mount fails with windows docker client against boot2docker #12751

skaegi opened this issue Apr 24, 2015 · 22 comments

Comments

@skaegi
Copy link

skaegi commented Apr 24, 2015

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?

@carloscasalar
Copy link

+1

@thaJeztah
Copy link
Member

/ping @ahmetalpbalkan (haven't tested this myself yet)

@ahmetb
Copy link
Contributor

ahmetb commented Apr 25, 2015

@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.

@thaJeztah
Copy link
Member

@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 #12751 (comment)

Thanks for reporting @skaegi, it's appreciated

@skaegi
Copy link
Author

skaegi commented Apr 27, 2015

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

docker run -it -v //myvol debian:jessie //bin/bash
docker run -it -v //myvol://myvol debian:jessie //bin/bash

but for now probably best to use either powershell or boot2docker ssh

@phazei
Copy link

phazei commented Jun 4, 2015

The double slash at the beginning works in most cases. But there's one in particular that won't work

docker exec -it web rsync -rvul --exclude='/vendor' //var/www/files_remote/ //var/www/files

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?

@ahmetb
Copy link
Contributor

ahmetb commented Jun 4, 2015

@phazei hmm actually if the argument starts with ', it doesn't do path conversion AFAIK as documented here. So maybe '--exclude=/vendor' would just work?

mlarcher added a commit to mlarcher/docker that referenced this issue Jun 28, 2015
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 explained in [issue moby#12751](moby#12751) but needs more visibility in the docs.

Signed-off-by: Matthieu Larcher <github@ringabell.org>
mlarcher added a commit to mlarcher/docker that referenced this issue Jul 3, 2015
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 explained in [issue moby#12751](moby#12751) but needs more visibility in the docs.

Signed-off-by: Matthieu Larcher <github@ringabell.org>
moxiegirl pushed a commit to moxiegirl/docker that referenced this issue Jul 5, 2015
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 explained in [issue moby#12751](moby#12751) but needs more visibility in the docs.

Signed-off-by: Matthieu Larcher <github@ringabell.org>
(cherry picked from commit 33be2c5)
calavera pushed a commit to calavera/docker that referenced this issue Jul 25, 2015
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 explained in [issue moby#12751](moby#12751) but needs more visibility in the docs.

Signed-off-by: Matthieu Larcher <github@ringabell.org>
tiborvass pushed a commit to tiborvass/docker that referenced this issue Jul 27, 2015
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 explained in [issue moby#12751](moby#12751) but needs more visibility in the docs.

Signed-off-by: Matthieu Larcher <github@ringabell.org>
@ktmswzw
Copy link

ktmswzw commented Mar 3, 2016

docker run -d --name redis-server -p 6379:6379 -v /h/redis:/var/lib/redis anapsix/redis

/h/redis = H://redis

@Avinash-Setty
Copy link

Recently I tried mounting using Docker Run command in Windows, still it doesn't work. Can anyone help me here?

avina@avinash-laptop MINGW64 ~
$ ll /c/development/phase2/Experiments/SimpleApp/src/SimpleApp
total 872
-rw-r--r-- 1 avina 197611    412 Mar 15 17:44 appsettings.json
-rw-r--r-- 1 avina 197611    207 Mar 15 17:43 bower.json
drwxr-xr-x 1 avina 197611      0 Mar 15 17:44 Controllers/
-rw-r--r-- 1 avina 197611   1249 Mar 15 17:43 gulpfile.js
drwxr-xr-x 1 avina 197611      0 Mar 15 17:44 Migrations/
drwxr-xr-x 1 avina 197611      0 Mar 15 17:44 Models/
drwxr-xr-x 1 avina 197611      0 Mar 15 17:43 node_modules/
-rw-r--r-- 1 avina 197611    213 Mar 15 17:43 package.json
-rw-r--r-- 1 avina 197611   1809 Mar 15 17:44 project.json
-rw-r--r-- 1 avina 197611 840603 Mar 15 17:50 project.lock.json
-rw-r--r-- 1 avina 197611   7006 Mar 15 17:43 Project_Readme.html
drwxr-xr-x 1 avina 197611      0 Mar 15 17:44 Properties/
drwxr-xr-x 1 avina 197611      0 Mar 15 17:44 Services/
-rw-r--r-- 1 avina 197611   1332 Mar 15 17:43 SimpleApp.xproj
-rw-r--r-- 1 avina 197611    241 Mar 15 18:05 SimpleApp.xproj.user
-rw-r--r-- 1 avina 197611   3928 Mar 15 17:44 Startup.cs
drwxr-xr-x 1 avina 197611      0 Mar 15 17:44 ViewModels/
drwxr-xr-x 1 avina 197611      0 Mar 15 17:44 Views/
drwxr-xr-x 1 avina 197611      0 Mar 15 17:43 wwwroot/

avina@avinash-laptop MINGW64 ~
$ docker run -v /c/development/phase2/Experiments/SimpleApp/src/SimpleApp:/SimpleApp -p 5000:5000 -it microsoft/aspnet
root@112446af63af:/# cd SimpleApp/
root@112446af63af:/SimpleApp# ls -al
total 4
drwxr-xr-x  2 root root   40 Mar 16 13:36 .
drwxr-xr-x 60 root root 4096 Mar 16 13:36 ..
root@112446af63af:/SimpleApp# exit

@thaJeztah
Copy link
Member

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

On 16 Mar 2016, at 13:58, Avinash-Setty notifications@github.com wrote:

Recently I tried mounting using Docker Run command in Windows, still it doesn't work. Can anyone help me here?

avina@avinash-laptop MINGW64 ~
$ ll /c/development/phase2/Experiments/SimpleApp/src/SimpleApp
total 872
-rw-r--r-- 1 avina 197611 412 Mar 15 17:44 appsettings.json
-rw-r--r-- 1 avina 197611 207 Mar 15 17:43 bower.json
drwxr-xr-x 1 avina 197611 0 Mar 15 17:44 Controllers/
-rw-r--r-- 1 avina 197611 1249 Mar 15 17:43 gulpfile.js
drwxr-xr-x 1 avina 197611 0 Mar 15 17:44 Migrations/
drwxr-xr-x 1 avina 197611 0 Mar 15 17:44 Models/
drwxr-xr-x 1 avina 197611 0 Mar 15 17:43 node_modules/
-rw-r--r-- 1 avina 197611 213 Mar 15 17:43 package.json
-rw-r--r-- 1 avina 197611 1809 Mar 15 17:44 project.json
-rw-r--r-- 1 avina 197611 840603 Mar 15 17:50 project.lock.json
-rw-r--r-- 1 avina 197611 7006 Mar 15 17:43 Project_Readme.html
drwxr-xr-x 1 avina 197611 0 Mar 15 17:44 Properties/
drwxr-xr-x 1 avina 197611 0 Mar 15 17:44 Services/
-rw-r--r-- 1 avina 197611 1332 Mar 15 17:43 SimpleApp.xproj
-rw-r--r-- 1 avina 197611 241 Mar 15 18:05 SimpleApp.xproj.user
-rw-r--r-- 1 avina 197611 3928 Mar 15 17:44 Startup.cs
drwxr-xr-x 1 avina 197611 0 Mar 15 17:44 ViewModels/
drwxr-xr-x 1 avina 197611 0 Mar 15 17:44 Views/
drwxr-xr-x 1 avina 197611 0 Mar 15 17:43 wwwroot/

avina@avinash-laptop MINGW64 ~
$ docker run -v /c/development/phase2/Experiments/SimpleApp/src/SimpleApp:/SimpleApp -p 5000:5000 -it microsoft/aspnet
root@112446af63af:/# cd SimpleApp/
root@112446af63af:/SimpleApp# ls -al
total 4
drwxr-xr-x 2 root root 40 Mar 16 13:36 .
drwxr-xr-x 60 root root 4096 Mar 16 13:36 ..
root@112446af63af:/SimpleApp# exit

You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub

@mathiasconradt
Copy link

I am having the problem on Windows 2016 Server TP4, without using boot2docker, since containers are supported there natively.
I try to mount a folder beneath C:\Users\myuser.. as data volume, like this:

docker run --name iisdemo2 -it -p 80:80 -v /c/Users/mlin/meinedaten:/c/meinedaten iis cmdclear

but it fails with an error:

docker : docker: Error response from daemon: Invalid bind mount spec "/c/Users/mlin/meinedaten:/c/meinedaten": volumeinvalid: Invalid volume specification:
'/c/Users/mlin/meinedaten:/c/meinedaten'.

Detailed issue report: http://superuser.com/questions/1051520/docker-windows-container-how-to-mount-a-host-folder-as-data-volume-on-windows

@thaJeztah
Copy link
Member

@mathiasconradt I think the "container" path for Windows containers needs to be a regular Windows-style path (forward slashes are accepted though), so

-v /c/Users/mlin/meinedaten:/c:/meinedaten

(c:/meinedaten instead of c/meinedaten)

@mathiasconradt
Copy link

@thaJeztah Thanks, you are right. I tried C: before but had left the trailing / in the front, which does not work. Not it's working, thanks a lot!

@thaJeztah Note that in this case, the docker documentation should be corrected, because on https://docs.docker.com/engine/userguide/containers/dockervolumes/#mount-a-host-directory-as-a-data-volume it still shows the path pattern incorrectly:

On Windows, mount directories using:

docker run -v /c/Users/[path]:/[container path] ...`

@SacredSkull
Copy link

SacredSkull commented Apr 4, 2016

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 or vim ~/.bashrc) and add export 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 run export 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 to C:/cygwin/unixy/path.

@adeelahmadch
Copy link

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;

volumes:
    - "/e/orchestration-workshop/dockercoins/webui/files/:files/"

i tried everything from // to ' but nothing worked for me. at the end i tried this workaround to make it work.

volumes:
    - "/e/orchestration-workshop/dockercoins/webui/files/"

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.

:-)

@mirasrael
Copy link

mirasrael commented Jan 12, 2017

@adeelahmadch I found Docker-compose has an option COMPOSE_CONVERT_WINDOWS_PATHS which solves this problem:

COMPOSE_CONVERT_WINDOWS_PATHS=1 docker-compose up -d

@laltman2
Copy link

@mirasrael thanks, this worked for me!

@SaiMunukutla
Copy link

docker run -itd -p 7776:7776 -v C:/temp/test:C:/testdir --name Test inet-test

This worked for me (y)

Going into Container :

docker exec -it powershell (for windows containers)

@DanJ210
Copy link

DanJ210 commented May 4, 2017

I couldn't get COMPOSE_CONVERT_WINDOWS_PATHS=1 docker-compose up -d to work I get red errors.

I'm just trying to run a basic tutorial volume thing that gives the above error response from daemon, invalid bind spec or not a valid repository/tag... Maybe someone can tell me how paths are supposed to be typed in via powershell. Like this line below, what am I typing wrong? How would I type that path? Thanks.

docker run -v /c:/Users:/data alpine ls /data

@DanJ210
Copy link

DanJ210 commented May 4, 2017

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.

@hugokoka
Copy link

hugokoka commented Oct 2, 2017

I solved it!

Add a volume:

docker run -d -v my-named-volume:C:\MyNamedVolume testimage:latest
Mount a host directory:

docker run -d -v C:\Temp\123:C:\My\Shared\Dir testimage:latest

@mtpultz
Copy link

mtpultz commented Nov 28, 2017

@DanJ210 did you ever figure out why you were getting that error due to the working directory? I've got the same issue and I can't figure out why it won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests