moby: Problem with -v shared folders in 1.6

System: Window 7/64

With:

Boot2Docker version 1.5.0, build master : a66bce5 - Tue Feb 10 23:31:27 UTC 2015 

docker run \
  -v /c/Users/Dieter/Documents/Gastrobase:/home/shiny/Gastrobase \
  hello-world

is a valid command. This is a simplified and function-less test version, see below for the “real” one. Note that /Dieter is a valid user, please replace for testing.

With

$ docker version
Client version: 1.6.0
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 4749651
OS/Arch (client): windows/amd64
Server version: 1.6.0
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 4749651
OS/Arch (server): linux/amd64

I could not find out how to define the path in -v; I tried several of the variants mentioned in the docs of 1.5 on shared folders.

$ docker run \
>   -v /c/Users/Dieter/Documents/Gastrobase:/home/shiny/Gastrobase \
>   hello-world
invalid value "c:\\Users\\Dieter\\Documents\\Gastrobase;C:\\Program Files (x86)\\Git\\home\\shiny\\Gastrobase" for flag -v: \Users\Dieter\Documents\Ga
strobase;C:\Program Files (x86)\Git\home\shiny\Gastrobase is not an absolute path
See 'c:\Program Files\Boot2Docker for Windows\docker.exe run --help'.

---- Real application -------------

docker run --restart=always --name gastrobase -d -p 3838:3838 \
  -v /c/Users/Dieter/Documents/Gastrobase:/home/shiny/Gastrobase \
  dmenne/gastro-docker


Dieter@DIETERPC ~
$ docker run --restart=always --name gastrobase -d -p 3838:3838 \
>   -v /c/Users/Dieter/Documents/Gastrobase:/home/shiny/Gastrobase \
>   dmenne/gastro-docker
invalid value "c:\\Users\\Dieter\\Documents\\Gastrobase;C:\\Program Files (x86)\\Git\\home\\shiny\\Gastrobase" for flag -v: \Users\Dieter\Documents\Ga
strobase;C:\Program Files (x86)\Git\home\shiny\Gastrobase is not an absolute path
See 'c:\Program Files\Boot2Docker for Windows\docker.exe run --help'.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 35 (9 by maintainers)

Commits related to this issue

Most upvoted comments

A hacky workaround for mysys is to use double leading slashes on the path:

docker run -v //c/Users/brettp/app:/app

@dmenne

If you’re using git bash on windows, msysgit converts paths like /c/users to c:\users (not something you want because the path inside the boot2docker VM is /c/Users)

Try surrounding -v value with single quotes like:

... -v '/c/Users:/path' ...

On cmd.exe/powershell you shouldn’t be having this problem. Does this solve the issue?

Update: (For people running into this while using git-for-windows’ flavour of msys) - I threw out the powershell script I was using earlier, and fixed the problem in the Makefile itself. I just exported MSYS_NO_PATHCONV=1 for any tasks which used linux-style paths or using pwd.

example:

.PHONY: init
init: export MSYS_NO_PATHCONV=1 # stop path conversion for msys in windows
init: ## Initialize a database
				docker run -u postgres --net host -v `pwd`/schemas/sql/postgres.sql:/tmp/setup.sql --rm postgres:9.5 psql -h localhost -U postgres -f /tmp/setup.sql code_db

Ref: https://github.com/git-for-windows/msys2-runtime/pull/11

@kumarharsh thank you. I fixed this by creating an bash script:

#!/bin/bash
export MSYS_NO_PATHCONV=1
docker run --rm \
-v mynamedvol:/data \
-v $PWD/data:/backup \
alpine \
sh "tar zcvf /backup/mybackup.tar.gz /data"

For everyone who still has a problem with mounting a folder on Windows. Make sure your drive letter is lowercase.

docker run -i -t -v /c/Users/Jakob/src:/mnt some_container

double // before win path works for me,thanks a lot:)

I figured out why the previous bug was happening: It was because my pwd was in D:\ drive, and D:\ drive is not mounted by default. To mount it, I followed the instructions given here: http://stackoverflow.com/a/32030385/630170

Now, the issue is that using git / msys2’s bash makes it impossible to mount the D:\ volumes using either of these:

(with leading slash)

docker run ... -v //d/Workspace/000_init.sql:/tmp/file --rm cat /tmp/file

which gives this error: cat: C:/Users/usr/AppData/Local/Temp/file: No such file or directory

or

(without leading slash) or (with single quotes) or (with double quotes)

docker run ... -v /d/Workspace/000_init.sql:/tmp/file --rm cat /tmp/file

which gives this error:

invalid value "D:\\Workspace\\000_init.sql;C:\\Users\\usr\\AppData\\Local\\Temp\\file" for flag -v: bad mode specified: \Users\usr\AppData\Local\Temp\file
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

docker run -v //c/Users/brettp/app:/app
Worked!