-
Notifications
You must be signed in to change notification settings - Fork 292
[WSL2] Mounting linux path as volume not working #4812
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
Comments
Thanks for reporting this. It will be fixed in an upcoming release |
Hi @simonferquel, I just tested it with 2.1.4.0 and the problem persists. |
This appears to still be an issue on 2.1.7.0 (41536). Is there a path towards resolution on this? This is kind of a deal-breaker? |
Just to add, according to: https://www.docker.com/blog/new-docker-desktop-wsl2-backend/ Under the Initial limitations section. It reads:
But as /etc/ is backed by the distro VHD, this is surely a bug? Oh, and it's still broken in 2.2.2.0 (43066) |
This is no more a limitation. Are you running the docker cli from your wsl distro? |
This was never an issue if running docker commands inside the WSL 2 VM, I mean, why would it? But that defeats the real point of having WSL 2 with the improved Docker compatibility in the first place. This issue is about not being able to run:
From a Windows command prompt, and for it to bind the |
To be clear, the issue that @flatline-studios presented is not the problem I'm having. I'm attempting to do something like:
And it generates the container, but the contents of the |
Just to clarify...
If the answer is yes to both of those, then we're describing the same issue. |
|
@john-landgrave |
@simonferquel - I'm not sure if I'm being clear enough about the issue that still exists.
C:\Development λ It seems that Docker for Windows isn't smart enough to look at the local mount directory A simple regex check My workaround at the moment is to just use two alias' in the Windows Shell:
Which then produce:
This is a very messy hack though, and I can imagine spending an hour pulling my hair out in a couple of months time, trying to work out why the following isn't working:
It would be looooooovely if Docker for Windows could just work out which filesystem we wanted to mount the directory from in the first place. |
@simonferquel I'm not showing any further updates presently and here's my version info: This still isn't working for me but is acting weird. Here's an account of the commands that I ran (all from within a WSL shell) and the output I got:
Where
Which is weird because that directory, which was mounted to
Here's where things get weird. When I
After My next thought was that somehow it was caching volumes that were being created or something like that? So I looked at For reference, I have also tried absolute paths on the left side of all of the I have also tried rebooting, factory resetting, and checking for updates after each of those things. Any ideas? @flatline-studios I think that we're definitely talking about two distinct issues, and I can't necessarily determine which one the original post is talking about (unless it's a third issue with a similar enough sounding description). If I need to make a new issue (@simonferquel ?) then I'm happy to, just don't want to muddy things up too much. |
Also, my diagnostics just finished @simonferquel and here is my diagnostics ID: B0076B2C-6E30-4CE4-B2B4-069CD453F0D3/20200304144117 |
@flatline-studios unfortunately we can't do that: we support integration with multiple distros, and we can't decide which to mount from. Also, historically, unix paths in mount sources from Windows means "mount something from the linuxkit environment" (which makes things like docker run -v /var/run/docker.sock:/var/run/docker.sock work). So we don't want to potentially break existing workflows there. @john-landgrave I'll have a look at the diagnostic file. |
@john-landgrave it might be related to a bug I fixed recently. Can you try this private build: https://download-stage.docker.com/win/edge/43174/Docker%20Desktop%20Installer.exe ? |
@simonferquel out for lunch right now, but I'll download it give it a shot when I get back in about an hour. |
@simonferquel I appreciate that, and thanks for clearing up the reasoning behind it. Much appreciated. Trying to find a better solution than my aliases, I tried using the Is there a simpler way to get around this? Like, instead of making Docker for Windows smarter, as I suggested with the regex... Wouldn't it be much easier to just tell Docker what we want. Like:
Or something similar? Using You mentioned the need to support multiple distros, and forgive my ignorance (I'm not well versed in the lower level Docker for Windows workings), but would that still be a problem with my proposed solution(s)? |
@simonferquel no dice: still have the same issue repeating the steps from my previous post. If it helps, when I just mounted Should I uninstall Docker before installing the build that you sent over? It seemed to update to 2.2.3.0 fine? |
Upgrading should be ok. Can you send a new diagnostic ? (This build as slightly more verbose logs) |
I had a similar issue today and gave up... Running latest edge, kubernetes, wsl2 on insider 2004, wsl2 enabled I have a deployment with specifications like this:
I received errors when k8 trying to start the image:
I tried changing all the Downgraded to Stable without WSL2 integration and now all is working fine. Hope that helps... |
@chadbr this is not the same issue. Mapping to windows drives is a bit different on wsl. To find which path to use, you can first create a container like |
@simonferquel I'm running diagnostics now and will drop the ID in here when I have it. EDIT: Here you go @simonferquel: B0076B2C-6E30-4CE4-B2B4-069CD453F0D3/20200305184205 |
@john-landgrave |
@simonferquel hmmm, I guess it could be user error? (Un)fortunately I'm in the hospital right now welcoming my new son into the world, but I'll be back at it next week. I would be open to doing a Zoom call when I get back if the diagnostics and/or me trying it again doesn't work. |
Congratulations! |
Wow, I think that's the first time we've had a bug report from the maternity ward. Congratulations! |
Thanks all! Babies are awesome and arguably a harder problem than building software on Linux in Windows! |
Hey @simonferquel I'm back at it now (though in quarantine like the rest of the world?). Here's the diagnostic ID with the container running: B0076B2C-6E30-4CE4-B2B4-069CD453F0D3/20200326211918 |
I feel like it's still a bit unclear what we're trying to do at Gigantum:
It seems that development priorities have been rapidly evolving in this general area (e.g., this comment and that we're not the only ones trying to do something like this. Our application was temporarily broken and we already deployed more complex logic that grabs the target bind-mount via inspecting the rewritten source in a test container. Maybe a bit of wasted effort given the above-linked change-of-heart. But on the flip side, it seems that something like the approach we already deployed should work here and be robust to changes - we're willing to do considerable work to be able to mount WSL2 volumes from a running container! Should I make another ticket? Or does my use case fit here? EDIT: I think I may have been confused about the persistence of
|
If you run |
Just want to confirm that this does work! I'm curious if the API has stabilized for when you call from windows also... so if I do a Or should we continue to inspect a container to get the re-written source path? (we do this currently - hopefully it doesn't break!) |
Previously we did not do anything particular when mounting /var/run/docker.sock from Windows, but it has changed very recently (not sure if it is in a public build yet). We now rewrite /var/run/docker.sock to the win32 proxy socket (so windows path mount sources will just work) |
I'm not sure if there's a way I can vote for the ability to mount wsl paths using the |
We are evaluating something a bit different... what if we exposed a CLI context for each integrated WSL distro, such that you could from Windows call |
After sleeping on it I went back to a different issue and your comment there: #5325 (comment) |
Hi @simonferquel, the main point of this issue was that I wanted to use the same docker-compose.yml (or complex docker command) for both linux and windows. In this regard using |
Sorry to be chiming in on this somewhat late - it relates to the question I was asking on Slack (#docker-desktop-win) . Does the above thinking include the ability to use libraries to access Docker from the perspective of a WSL distro? In our case, we currently use dockerode - but a casual inspection shows me that several libraries in multiple languages only accept either a file path or an HTTP URL. It would be great to have some syntax to specify the target proxy for these libraries. EDIT: one approach could be for my application to create a named pipe that transparently wraps the WSL2 socket? |
Hello. Facing the same issue with WSL2. (i just have one WSL2 Linux Distro installed). Thanks |
@SJRM78 from a WSL 2 terminal, you can just |
Hello. This is what i am doing (all from WSL2 terminal)
i get this :
then i run
and i get this error However, if i run
it works. I can find inside the docker container, in the /home/app folder the files expected. There is a similar problem mentioned above, but with kubernetes
but the folder /home/app/src in the kubernetes pod is empty. no files there EDIT : I have run the same commands with alpine instead of busybox, and the results are the same |
Ah, indeed, named volumes of type bind are not supported. You need to use bind mounts, not named volume mounts with type bind. |
thanks. i can do that in docker cli. :) I'm curious, is there a plan to support named volumes ? Thanks |
@SJRM78 It is possible to get this working though it's not persistent - see my comment #5325 (comment) for how I got it working, but note the comment earlier in that thread: "Please note that this will break if you restart without recreating the bind mount before running docker though." So from your example, you should do something like:
Then change the host path in your configuration to |
Thanks @TroyLaurin i will try now. It would be great if in a future version of docker this is possible to be handled in a more transparent and friendly way |
Kubernetes is much more complicated for us to work with, as we can't really intercept api calls and rewrite things, as most pod creations are done indirectly by server-side components instead of from an identifiable client. However, what we can probably do is provide a persistent volume class driver that you could use in your kubernetes yaml (we already implement a storage driver that stores volumes data in docker-desktop-data distro). The idea would be to declare a persistent volume (or volume claim) with StorageDriver set as |
I just wanted to drop an update here and relay that for our desktop app for Gigantum on Windows, we are just going to do a subshell command to launch our container from within the Linux distro of choice. It's a little annoying, because you need to do some escaping to make sure Powershell doesn't replace variables, but this works from Powershell for example:
Probably you won't need the
And you'll also see the dynamically determined home directory at |
Have the same problem/need. To get it, I define the volume in advance:
Then, within the docker-compose.yml I use it the volume as external: Seems to work at the first execution but if I stop the containers (docker-compose down) and try to up them again, it fails trying to mount the volume... saying: Why it fails? and... what it works just the first time?? |
Issues go stale after 90 days of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
Expected behavior
Mounting linux path (e.g.
/etc/timezone
) as volume should mount that path from within wsl machine.Actual behavior
The path
c:\etc\timezone
(/mnt/c/etc/timezone
within wsl machine) is actually mounted as volume. If it does not exist it creates it as empty folder.Information
Steps to reproduce the behavior
Notes
Be able to mount linux paths from within wsl/virtual machine is essential to be able to use my containers that I am already using in linux in production, since all of them mounts at least
/etc/timezone
and/etc/localtime
to inherit timezone configuration of the host.The text was updated successfully, but these errors were encountered: