-
Notifications
You must be signed in to change notification settings - Fork 829
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
Docker-compose and incorrect absolute paths for volumes #1854
Comments
So, this is a little more conceptually complicated: Unlile in Cygwin, In this particular case, maybe you could try putting an absolute Windows path in your config file? You might also want to bring this up on the Docker forums -- they seem to be pretty active, and the Docker team seems to care a lot about compatibility. (And this would be a really easy, if kind of hackish, thing for them to work around.) |
Within the Hyper-V VM, the |
And in MSYS as well, which is how the whole Windows Git BASH world sees things. I know that mounting remote shares on |
@sakai135 -- ah, interesting: I initially assumed Docker for Windows did Windows path translation server-side but it would make a lot of sense for it to do it client-side (in which case the Linux client would indeed need to pass in a VM-compatible path). @therealkenc -- ooh, that's a good thought: WSL already supports bind-mounts. Therefore it does (in essence) support mounting DrvFS on arbitrary paths. So, proposed workaround (untested):
|
@aseering the bind mount worked for me :) Thanks for the workaround! |
I forgot binding works. Perfect. Once real |
@aseering you made me realize that it was unusual that the WSL docker client was taking non-canonical paths as arguments, so I went back and tried $ docker run --rm -v /mnt/c/Users/ej3/dev/play/:/var/play bash ls -la /var/play
total 4
drwxr-xr-x 5 root root 100 Apr 5 21:05 .
drwxr-xr-x 1 root root 4096 Apr 5 21:47 ..
drwxr-xr-x 2 root root 40 Apr 5 20:58 Dockerfile
drwxr-xr-x 2 root root 40 Apr 5 21:02 configure.file
drwxr-xr-x 2 root root 40 Apr 5 21:05 test.dev.conf which seemed to work! (but the listing wasn't complete?!) so then I had no idea what the problem could have been, and I panicked a bit. Then the conversation went on, and the $ docker run --rm -v /c/Users/ej3/dev/play/:/var/play bash ls -la /var/play
total 12
drwxr-xr-x 2 root root 4096 Apr 5 21:44 .
drwxr-xr-x 1 root root 4096 Apr 5 21:47 ..
drwxr-xr-x 2 root root 0 Apr 5 21:44 .git
-rwxr-xr-x 1 root root 81 Apr 5 21:10 Dockerfile
-rwxr-xr-x 1 root root 675 Apr 5 21:44 README.md
-rwxr-xr-x 1 root root 139 Apr 5 21:19 bash_it.sh
-rwxr-xr-x 1 root root 116 Apr 5 21:04 docker-compose.yml
-rwxr-xr-x 1 root root 39 Apr 5 21:09 test.conf
-rwxr-xr-x 1 root root 40 Apr 5 21:08 test.dev.conf
$ Then I was able to reproduce my issue with a simple Just a further note: When I first tried using the Thanks. |
I wanted to do the same a few months ago. I ended up simply symlinking sudo ln - s /mnt/c /c Not sure if it's better performance-wise than bind-mounting, but it works just as well. |
For what it's worth, there are some applications (Web servers in particular) that will deliberately refuse to read files from any path that contains a symlink. Usually for security reasons, because malicious users could use symlinks to escape DocumentRoot. Bind mounts usually don't suffer from this limitation -- anyone can create a symlink anywhere, but you need elevated permissions (traditionally, root) to set up a bind-mount, so sysadmins can still use them but they're harder to exploit. |
Hi folks, We're talking this over internally at Microsoft and open to suggestions. From Russ on the WSL (Windows Subsystem for Linux) team: "Bind and symlinks both work, but the bind may be better in some cases since not all services will follow symlinks. Downside of bind is that it will not stick between WSL instances due to our init." Essentially agreeing with @aseering's points :) What ideas do you have? What are you trying to do when you run into problems around file paths? Cheers, |
From my holistic point of view, the ideal solution would be for all us (and I really expect it happen some day), iff WSL will converge with Docker and Docker on Windows will move to use WSL compatibility layer instead of MobyLinux VM. In this case Docker Compose could be used the way it is used on Linux and transparently rely on WSL underneath. |
Thanks for the suggestions! |
Do you need to
|
Has anyone found a way to make |
(beware for wsl: microsoft/WSL#1854 and docker/for-win#371 (comment))
@DeadPixelz01 For me docker/for-win#371 (comment) works quite well |
oh my god @aseering ily. you just helped me finally jump through the last of the many fiery hoops that line the pathway to getting docker fully operable from within lxss |
@aseering Not to pester, but is there any update on this? I'm struggling to get the bind mount workaround to work reliably. IMO, This is one of the last things holding back the WSL finally being a decent developer environment on Windows. |
Hm, I don't know of any update. But I'm not actually a WSL dev; just a user. Maybe someone on the WSL team can comment? For the bind-mount, what have you tried? And have you tried a symlink instead? We might be able to help you with those, too. |
@aseering Thanks for the offer of help. I did eventually get this working with the bind mount. Turned out my config was the issue - of course. Today Microsoft released insiders build 17093. In the release notes it states:
I thought this might be of interest to @edrevo who previously mentioned The notes also mention:
Would anyone with a bit more knowledge be able to say if these changes affect this issue at all? |
@pd93 - yes the addition of fstab support adds a better way to configure mounts. AF_UNIX support is new functionality that allows WSL processes and Windows processes to communicate and should not impact this. See the blog post for more details. |
Regarding AF_UNIX, in principle Docker for Windows should be able to use that to allow WSL/Linux applications to talk over a local socket (just like native Linux Docker) rather than TCP/loopback. I haven't read this part of Docker's source code, but I would guess that they would need to make some small modifications to their code: Previously, AF_UNIX didn't work and wasn't available on Windows, so existing applications will often avoid even trying it on Windows. |
There is OTOH one new feature that might be of relevance here. On
It also added other DrvFS options handling. |
@villasv I can confirm that adding the following to the
I brought up my docker project and can access all of my volume mounts 👍 |
@benhillis Is there a way to obtain the root mount point from from the wsl command line without having to parse the |
@pd93 - No there is not. |
@pd93 you can get similar information by parsing |
I can get this to work, but it doesn't respect the file permissions I set in WSL. Thanks to recent changes, I can set keys on my windows system to 600 through WSL (I think it uses the drvfs filesystem and attaches some metadata to it). These changes aren't visible on the volume mount. Every file ends up with the same permissions, just like when I run docker from powershell. |
How to access WSL filesystem from composer? |
Did anybody experience mounted volumes to list just partial contents when accessed from container? I followed the hints provided here to mount bind /mnt/c as /c and /mnt/d as /d, as well as using symlinks, but the behavior of listing volume from docker container sometimes shows empty dir, sometimes only some of the files/directories that are present on host, sometimes all contents. I'm using Docker Toolbox with docker machine on Virtual Box and command like |
The mounts seems to be working fine, I can access all content without problem in /d, however when I mount /d as volume to docker container, it shows empty dirs (seems like it memoizes the subdirs that I tried to mount as volumes and shows just them, so running with /d, then /d/subdir, then /d will show subdir as content in last step). It works somewhat better for /c than for /d though... For /c I can correctly access /c/Users/kamil and all contents in subdir, for /d there is nothing at all. Maybe Docker Toolbox VM is not actually mounting D: and for C: maybe it's a different problem. |
Ah, ok. For Docker Toolbox (using VirtualBox) you can actually map drives (host C: or D:) under (guest, visible to docker containers) /mnt/c /mnt/d directories, so the workarounds mentioned in this issue could be skipped and the problem solved through VM settings. |
Hello! it was just as simple as "Reset credentials" in Docker "Shared drives", update password to current and restart Docker (in reset menu). Maybe it will help somebody too. |
I faced the same issue with docker-compose as well, by default Docker Toolbox for Windows only has access to C:\Users. Additional directories can be shared via VirtualBox UI. |
I think the bind trick is a hack, this should be made to work:
Having to bind the drive first, then navigating to that new fake drive, makes things really complicated. If you already have a development setup with scripts that run the docker-compose, this is annoying thing. I can't go and edit the development scripts because they are correct. Right now I should do a new script just for WSL, and that is clunky. |
windows 10 build 1503.11 running Xenial 16.04.2 LTS with docker client 17.03.0 connecting to the hyper-V docker-for-windows daemon 17.03.1 and docker-compose 1.11.1
From within wsl things like
docker run --rm -v c:/my/stuff:/var/goes/here bash ls /var/goes/here
work fantastically. This command will simply list the contents ofc:/my/stuff
.What does not work is If you have a
docker-compose.yml
that looks like:and you run something like
docker-compose -p test -d bash_it up && docker exec test_bash_it_1 ls /var/goes/here
. Everything will explode and die - you may have to restart the docker-for-windows daemon / engine.the error will look something like:
It's all rather complicated looking, but I'm pretty sure I can tell you what's going on: the windows-for-docker daemon expects a valid windows path (eg
c:/my/stuff
) BUTdocker-compose
is callingos.path.abspath
to resolve the absolute path of the resource and it's getting a URI/path that looks like/mnt/c/my/stuff
- which is absolute nonsense unless you're in the windows linux subsytem.. which the hyper-v daemon is clearly not.so... that's an interesting problem. Is there a switch like
MSYS_NO_PATHCONV=1
or something I can do to preventos.path.abspath
from returning a wsl alias? OR - how should this work?The text was updated successfully, but these errors were encountered: