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

Broken volume mounting under Windows #18756

Closed
waynew opened this issue Dec 17, 2015 · 32 comments
Closed

Broken volume mounting under Windows #18756

waynew opened this issue Dec 17, 2015 · 32 comments

Comments

@waynew
Copy link

waynew commented Dec 17, 2015

When running Docker (1.9) under Windows 8, attempting to mount a volume fails miserably:

$ docker run --entrypoint /bin/sh -it -v "/c/Path To My Repo:/myprogram" my_test
invalid value "C:\\Path To My Test\\;C:\\Program Files\\Git\\myprogram" for flag -v: bad mode specified: \Program Files\Git\myprogram
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

This is being run from the mingw prompt.

What am I doing wrong here?

@thaJeztah
Copy link
Member

Does the path you're trying to mount contain a space? Then this may be a duplicate of #18120, which will be solved by #18206 once merged.

@pewsey
Copy link

pewsey commented Dec 18, 2015

I have the same issues. Not using paths with spaces. Windows 10.

This same image works perfectly under MacOS/X (where it was created)

$ docker run -it joneaves/xxx Use of uninitialized value $source_realm in open at /app/find_them.pl line 31. Use of uninitialized value $source_realm in concatenation (.) or string at /app/find_them.pl line 31. Could not open file '' No such file or directory at /app/find_them.pl line 31.

This is the container running "correctly" (and I'm not passing in the volume information)

docker run -v $(pwd):/cah joneaves/xxx /cah/d10.csv /cah/m10.csv

Works fine on MacOS - but under Windows 10 I get

$ docker run -v $(pwd):/cc joneaves/xxx invalid value "C:\\Users\\jon\\coding\\cah;C:\\Program Files\\Git\\cc" for flag -v: bad mode specified: \Program Files\Git\cc See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

Note the rather weird extraneous "C:\Program Files\Git" - which confuses me. So, how about using that winpty command for docker to see what happens

$ winpty docker run -v $(pwd):/cc joneaves/xxx invalid value "C:\\Users\\jon\\coding\\cah:\\cc" for flag -v: bad mode specified : \cc See 'docker run --help'.
Well, at least it's not complaining about Git this time.

Changing to not use $(pwd) and actually specify the path doesn't help either.

$ winpty docker run -v /c/Users/jon/coding/cah:/cc joneaves/xxx invalid value "C:\\Users\\jon\\coding\\cah:\\cc" for flag -v: bad mode specified : \cc See 'docker run --help'.

All of this is done using a terminal created from the Docker Quickstart on Windows

`
$ docker version
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: a34a1d5
Built: Fri Nov 20 17:56:04 UTC 2015
OS/Arch: windows/amd64

Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: a34a1d5
Built: Fri Nov 20 17:56:04 UTC 2015
OS/Arch: linux/amd64
`

@thaJeztah
Copy link
Member

@pewsey thanks for the detailed repro steps! I don't have access to a windows machine, but wondering if adding a double slash helps;

winpty docker run -v //c/Users/jon/coding/cah://cc joneaves/xxx

I think that prevented some "magic" conversion

@pewsey
Copy link

pewsey commented Dec 19, 2015

$ winpty docker run -v //c/Users/jon/coding/cah://cc joneaves/xxx invalid value "\\\\c\\Users\\jon\\coding\\cah:\\cc" for flag -v: \cc is not an a bsolute path See 'docker run --help'.

Is the result.

From my (brief) understanding - the winpty command "should" fix all that escaping issues. I suspect it's something more heinous happening under the covers.

@pewsey
Copy link

pewsey commented Jan 11, 2016

Is there an update on this one? Fixed in a future build? Never to be fixed?

@legrandjeremy
Copy link

Hi all,

I'm running Windows 10 and I can't use mount volume with docker. I have no error displayed but all sync folders are empty.

I hope a fix or workaround can be quickly deployed.

@thaJeztah
Copy link
Member

ping @jhowardmsft is this something that needs a fix in docker/docker?

@lowenna
Copy link
Member

lowenna commented Jan 13, 2016

At a Linux or Windows daemon? No idea about the winpty thing, I just run from native cmd or Powershell, not from bash and winpty that might inappropriate munge and escape paths (such as the double back-slashes in the example). If pointing at a Windows daemon, it needs to be in Windows semantics. eg docker run -v c:\path:d:. If pointing at a Linux daemon, it needs to be in Linux semantics eg docker run -v /foo:/bar. All this assumes you are running a daemon and client with the volume PR merged (such as TP4 or later, can't remember exact date of merge, but something like Nov 23rd was TP4 final, I think you're close on Nov 20th).

@pewsey
Copy link

pewsey commented Jan 13, 2016

@jhowardmsft thanks for that. You can see my attempts above. Can you craft me a working command line from your perspective. It would be great if you could try it using the Windows "Docker Quickstart".

I'm not 100% convinced it's not me doing something insane - but I have tried a few permutations which I've documented above and it's not behaving like I'd expect.

If there's anything else I can do to help this - please feel free to reply to me here. I'd really like to know how to get this to work.

For clarity - the host environment is Windows 10 and the VirtualBox environment is Ubuntu.

@lowenna
Copy link
Member

lowenna commented Jan 13, 2016

I don't have a "Docker Quickstart", never used it. Just an Ubuntu VM on Hyper-V running docker. Pointing at it from a Windows box: Top window shows the directory contents on the Linux box. Blue windows is on Windows starting a container with a bind mount of /foo into /bar in the container, and subsequently showing the same contents.
volume

@waynew
Copy link
Author

waynew commented Jan 13, 2016

@jhowardmsft That's not the problem that we're having here. Docker running on an ubuntu VM under Windows isn't quite the same as installing the Docker Toolbox on Windows ;)

Which is where the problem is. Your docker client is just talking to the docker daemon inside your VM, mounting a linux path.

our problem is trying to mount a Windows path, like this:

Windows Machine
+-------------------------------+
|                               |
|  Docker VM (VirtualBox)       |
|  +-----------------------+    |
|  |                       |    |
|  | +------------------+  |    |
|  | | Docker Container |  |    |
|  | |                  |  |    |
|  | | /foo --,         |  |    |
|  | +--------|---------+  |    |
|  |        __|            |    |
|  |       /               |    |
|  |     ,/                |    |
|  |     V                 |    |
|  | /c/Path to/foo -,     |    |
|  +-----------------|-----+    |
|                   /           |
| C:\Path to\foo <-'            |
+-------------------------------+

But it doesn't work. Miserably so :(

@lowenna
Copy link
Member

lowenna commented Jan 13, 2016

Ah, AFAIK you can't do that from either a Linux or a Windows client. The volume is on the host running the daemon, not on the client.

@waynew
Copy link
Author

waynew commented Jan 13, 2016

@jhowardmsft You can mount any folder that the daemon can see. Macs have a similar layout (only mac, not Windows, of course). On my Mac I have no problem doing the same thing.

The virtual machine that Docker creates mounts the C: drive as /c/ - you can verify this if you install the docker toolbox and run docker-machine ssh default, then ls /c/. The drives are mounted. You can even see in my original post that Docker translates to the Windows version of the path. And then dies.

@tiborvass
Copy link
Contributor

@waynew do you have any logs we can have a look at?

@tiborvass
Copy link
Contributor

Oh nvm, it's a client-only issue?

@waynew
Copy link
Author

waynew commented Jan 13, 2016

I assume it's a server issue. I don't actually have a Windows machine at my disposal, but I suspect this is the case for any/all windows machines that try to mount a windows volume in the container.

@cpuguy83
Copy link
Member

This looks like a client issue, particularly with mflag parsing the options.

@pewsey
Copy link

pewsey commented Feb 24, 2016

$ docker version
Client:
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:14:21 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 20:39:58 2016
 OS/Arch:      linux/amd64

This issue is resolved for my particular use case. Thank you for whatever happened. I suspect it was as cpuguy83 mentioned - some CLI parsing errors.

@thaJeztah
Copy link
Member

Thanks @pewsey

@waynew can you confirm if this is resolved for you as well on 1.10.x?

@ppisljar
Copy link

i am still having this issue

  • docker toolbox installation
  • docker version 1.10.2
  • windows 7

actually its behaving really weirdly

i tried this:

$ docker run -ti -v /c/:/c_drive debian:latest bash
root@3cd5ac7d0dc7:/# cd /c_drive/
root@3cd5ac7d0dc7:/c_drive# dir
Program\ Files\ (x86)  Users  js

as you can see, some folders are shown ... but most are not ....

  • in Users there seems to be everything (folders + all files)
  • in program files there is just the docker folder
  • in js there is nothing ... but it was not showing before ... only after i tried to mount this specific folder ...

anyway, the problem is the same. when i mount a folder from windows machine ... its empty inside docker container.

however mounting /c/Users works as expected ...

@thaJeztah
Copy link
Member

@ppisljar I think that is expected; by default, only the C:\Users directory is shared with the Virtual Machine through virtual box file sharing; https://github.com/boot2docker/boot2docker/#virtualbox-guest-additions

@4gekkman
Copy link

I have same problem as @legrandjeremy

I'm running Windows 8.1 and I can't use mount volume with docker. I have no error displayed but all sync folders are empty.

For example, i have file in c:\users\german\volumes on my host windows machine.
I run in powershell:

              docker run `
                -it `
                --volume /c/users/german/volumes:/german `
                ubuntu:14.04 `
                /bin/bash

And folder /german in container is empty.
How can we deal with it?

@tiborvass tiborvass added this to the 1.10.3 milestone Feb 26, 2016
@ppisljar
Copy link

i got it working with -v /c/Users/german/volumes:/german (note the capital U in users)

thanks @thaJeztah

@thaJeztah
Copy link
Member

Good to hear, and that actually makes sense, because the Virtual Machine runs Linux, and uses a case-sensitive filesystem, therefore /c/Users and /c/users is not the same.

@4gekkman
Copy link

I'v found why this doesn't work:

              docker run `
                -it `
                --volume /c/users/german/volumes:/german `
                ubuntu:14.04 `
                /bin/bash

Because container runs not with -d (as daemon), and after run we immediately have command line to container. And in this point of time, has not yet finished mounting, and that's why we have empty folder.
If i exit
and again docker exec -it [container] /bin/bash
i see not empty folder.
And it's case insencitive, no matter

/c/users/german/volumes:/german

or

/c/Users/German/Volumes:/german

But if instead:

--volume /c/users/german/volumes:/german

i use:

--volume /c/users/german/volumes

i still have empty folder in container. Any ideas?

My bad
I had some misunderstood volumes
Now everything is fine =-}

@thaJeztah thaJeztah removed this from the 1.10.3 milestone Mar 4, 2016
@bizmate
Copy link

bizmate commented Apr 8, 2016

I am running on 1.10.3. Noticed @thaJeztah removed this from 1.10.3 but I am still experiencing the problem.

For instance with

version: '2'

services:
  data:
    container_name: data_mounts
    image: busybox
    volumes:
      - ./logs:/logs
  web:
    container_name: web_proxy
    image: nginx:stable
    ports:
      - 80:80
    volumes_from:
      - data
    #volumes:
    #  - ./docker/config/nginx.conf:/etc/nginx/nginx.conf:ro

if I then go on the machine and do ls on /logs the folder is empty

$ docker exec -it web_proxy bash
root@1abe18c00b73:/# ls /logs/
root@1abe18c00b73:/#

Also I am not sure if related to Windows or the container. If uncommenting the docker nginx.conf volume abote i also get error


$ docker-compose up -d
Starting data_mounts
Recreating web_proxy
ERROR: Cannot start container 1d4bacb70be8702f98e77c8faac1e33bd7b67d44f8c4ed1684fbc414cfb7a035: [9] System error: not a directory

Is these related to this issue? Any suggestions? Should i open a separate one?

@gabehesse
Copy link

I'm running version 1.12.0.
docker run -it -v /c/Users/BAMF/codes/TNT:/app tnt_web /bin/bash
This command did not give an error or warning, resulted in an empty /app directory in my container.
I used the little whale icon in the taskbar to go to a settings/shared drives screen. I checked off the C drive and clicked Apply. It made me enter my windows credentials. I reset docker from the Settings menu after this change. Now the same command resulted in a properly mounted /app directory.

@sudoforge
Copy link

I can confirm that the process described by @gabehesse results in a properly mounted volume (located on the drive(s) selected in Docker for Windows client's settings) on a new installation of Windows 10.

@fehergeri13
Copy link

image
This solves the problem

@sudoforge
Copy link

To clarify, @fehergeri13 posted a screenshot of the solution provided by @gabehesse.

@cfstras
Copy link

cfstras commented Sep 7, 2016

For a mingw bash shell, this is what docker toolbox adds (for example in bashrc) to stop mingw from corrupting the paths:

docker () {
  MSYS_NO_PATHCONV=1 docker.exe "$@"
}
export -f docker

@thaJeztah
Copy link
Member

I'm closing this issue because all issues reported here seem to either be an issue with mingw, docker toolbox / VirtualBox guest additions, or docker for windows; for issues with "docker for windows", please use the dedicated issue tracker: https://github.com/docker/for-win/issues. For docker toolbox, please use https://github.com/docker/toolbox/issues.

This is not a bug in the "docker engine", so there's not a lot we can do in this repository, so I'll close

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