You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mounts stop receiving inotify change events from Windows host #8479
[x] I have tried with the latest version of my channel (Stable or Edge): tested under edge 2.3.6 47622 and stable 2.3.0.4 46911
[x] I have uploaded Diagnostics
Diagnostics ID: F6FACDFC-D90A-40E8-8A1A-FC5A6D749036/20200915092839
Windows Version: Microsoft Windows 10 Pro 2004 19041.508
Docker Desktop Version: edge 2.3.6 47622 and stable 2.3.0.4 46911
Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: No
Expected behavior
File change events from editing in the host should propagate to the container to enable tools like modd, nodemon or webpack to re-compile files in-container.
Actual behavior
Event triggered when changes happen within the container but not when on host. The problem existed in the past #5701 but seems to have reappeared in the latest Docker for Windows versions.
$ docker-compose up --detach
Creating network "inotify-wait_default" with the default driver
Creating test ... done
$ winpty docker exec -it test sh
/ # apk add inotify-tools
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/1) Installing inotify-tools (3.20.2.2-r0)
Executing busybox-1.31.1-r16.trigger
OK: 6 MiB in 15 packages
/ # inotifywait --event modify,create,delete --recursive /tmp/ &
/ # Setting up watches. Beware: since -r was given, this may take a while!
Watches established.
# event properly captured when file is created inside docker container
/ # touch /tmp/test
/tmp/ CREATE test
[1]+ Done inotifywait --event modify,create,delete --recursive /tmp/
/ # inotifywait --event modify,create,delete --recursive /tmp/ &
/ # Setting up watches. Beware: since -r was given, this may take a while!
Watches established.
/ # exit# event not captured when file is created on host
$ touch tmp/test2
Thanks for the report, @8ctopus. Are you running Docker in WSL 2, but keeping your files in the Windows file system instead of the Linux file system? If so, then this is expected (and documented, and out of our control because we don't manage the file sharing in that scenario).
@stephen-turner Thank you so much for your reply, I've been trying to figure out where the problem comes from for 4-5 hours. I've just disabled WSL 2 and everything works again as it should. It's unfortunate that the better WSL 2 breaks that functionality and I had to revert to Hyper-V.
The alternative is to use WSL 2 but keep your files on the Linux side. That's what we recommend for best performance.
@stephen-turner What exactly do you mean by "keep files on the linux side?" (I'm to much of a Linux person). To physically move the files into the wsl2 Ubuntu VM?
I thought that if you use for example -v /mnt/d/some/folder:/folder that you're using the Linux file system, even if the files are hosted in Windows (in the case of previously using the Hyper-V version of docker, and not physically moving any files)?
I'm having issues getting my "old" Hyper-V mounts to work as well after upgrading to wsl2 and I'm not sure why? When looking at the paths it all seems OK:
@stephen-turner I have no problem doing that in cases where the files may be small, such as simple config files, but what about in cases like for example, Nextcloud, where the binded mounts can be terabytes? (I use an external 2tb drive bind mounted to that container).
I don't understand why using /mnt/ isn't working at all? Do bind mounted paths still need to be "shared" in linux, the way they did using the Docker GUI for Hyper-V? if so, how does one "share" paths in Linux?
Update:
I copied the file into the Ubuntu WSL vm at: \\wsl$\Ubuntu\home\me\docker\DNSCrypt\dnscrypt-proxy.toml and it still won't mount when I use either:
Sure, I get that some files are difficult to move out of the Windows filesystem. But unfortunately we do not control the file sharing across the WSL boundary, it's wholly managed by Windows, so we can't do anything to optimise it. Your alternative is to stick to Hyper-V instead of WSL 2.
Sure, I get that some files are difficult to move out of the Windows filesystem. But unfortunately we do not control the file sharing across the WSL boundary, it's wholly managed by Windows, so we can't do anything to optimise it. Your alternative is to stick to Hyper-V instead of WSL 2.
So in order to use Nextcloud, or other containers that need lots of storage space, like torrent clients, NZB clients, etc. we have to stick with the Hyper-V version and lose out on all the WSL2 benefits? :/
Does it work if you do a simple docker run -v instead of using a compose file?
Hmmm, I think you're onto something, but I don't have enough experience to know what, lol.
When I do:
docker run -v ~/.docker/configs/DNSCrypt/dnscrypt-proxy.toml:/config/dnscrypt-proxy.toml -h dnscrypt-proxy --network dns -p 5252:5053/udp -e TZ=America/Chicago klutchell/dnscrypt-proxy:latest
It works, but using this in compose (I use Portainer), I get the error shown above:
Well, I guess so. I mean, the only options are (1) Hyper-V (2) WSL 2 but files in Windows, which has performance problems (3) WSL 2 with files in WSL 2.
I'm not sure either, but I notice something else that might be relevant. The error message referred to /docker/DNSCrypt/dnscrypt-proxy.toml as the file that doesn't exist. Is $HOME perhaps blank in this context?
In our experiments it is worse, yes. Exactly how much worse depends on the nature of your workload: it can be anything from a few percent to multiples. The biggest penalty is when you have frequent accesses to lots of small files.
Living wholly within the WSL 2 world is always fastest, if you can achieve that.
btw inotify events have never worked for files stored on filesystems that come from a VMs "shared folder strategy" (it's essentially coming into your vm via Samba).
In case someone stumbles over this problem as well and isn't quite sure how to set up the dev environment with VS Code, WSL2, Docker Desktop, a dev container and a mounted directory with the cloned repo (i.e. source code), then here is an article that describes the root cause and also how to avoid it by keeping all files in the Linux file system.
I researched and wrote the article over the last few weekends and hope it'll help save you some time or at least provides some additional insights into what is happening.
Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.
Prevent issues from auto-closing with an /lifecycle frozen comment.
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.
/lifecycle stale
Activity
stephen-turner commentedon Sep 15, 2020
Thanks for the report, @8ctopus. Are you running Docker in WSL 2, but keeping your files in the Windows file system instead of the Linux file system? If so, then this is expected (and documented, and out of our control because we don't manage the file sharing in that scenario).
8ctopus commentedon Sep 15, 2020
@stephen-turner Thank you so much for your reply, I've been trying to figure out where the problem comes from for 4-5 hours. I've just disabled WSL 2 and everything works again as it should. It's unfortunate that the better WSL 2 breaks that functionality and I had to revert to Hyper-V.
stephen-turner commentedon Sep 15, 2020
The alternative is to use WSL 2 but keep your files on the Linux side. That's what we recommend for best performance.
8ctopus commentedon Sep 15, 2020
@stephen-turner Thank you again, I'll try that. I'm completely new to WSL 2 so don't have any experience with it yet.
YouveGotMeowxy commentedon Sep 15, 2020
@stephen-turner What exactly do you mean by "keep files on the linux side?" (I'm to much of a Linux person). To physically move the files into the wsl2 Ubuntu VM?
I thought that if you use for example
-v /mnt/d/some/folder:/folderthat you're using the Linux file system, even if the files are hosted in Windows (in the case of previously using the Hyper-V version of docker, and not physically moving any files)?I'm having issues getting my "old" Hyper-V mounts to work as well after upgrading to wsl2 and I'm not sure why? When looking at the paths it all seems OK:
That's from a compose that looks like this:
stephen-turner commentedon Sep 15, 2020
Yes keep your files in the WSL 2 filesystem. Don't share them across the VM boundary because it's unperformant and you lose inotify.
YouveGotMeowxy commentedon Sep 15, 2020
@stephen-turner I have no problem doing that in cases where the files may be small, such as simple config files, but what about in cases like for example, Nextcloud, where the binded mounts can be terabytes? (I use an external 2tb drive bind mounted to that container).
I don't understand why using /mnt/ isn't working at all? Do bind mounted paths still need to be "shared" in linux, the way they did using the Docker GUI for Hyper-V? if so, how does one "share" paths in Linux?
Update:
I copied the file into the Ubuntu WSL vm at:
\\wsl$\Ubuntu\home\me\docker\DNSCrypt\dnscrypt-proxy.tomland it still won't mount when I use either:or
it shows the error:
stephen-turner commentedon Sep 16, 2020
Sure, I get that some files are difficult to move out of the Windows filesystem. But unfortunately we do not control the file sharing across the WSL boundary, it's wholly managed by Windows, so we can't do anything to optimise it. Your alternative is to stick to Hyper-V instead of WSL 2.
No, you do not need to share files in the UI like you do in Hyper-V. I'm not sure why your example didn't work, but I did find this on stack overflow: https://stackoverflow.com/questions/48971065/getting-invalid-mount-config-for-type-bind-bind-source-path-does-not-exist-in. Does it work if you do a simple
docker run -vinstead of using a compose file?YouveGotMeowxy commentedon Sep 16, 2020
Thanks @stephen-turner
So in order to use Nextcloud, or other containers that need lots of storage space, like torrent clients, NZB clients, etc. we have to stick with the Hyper-V version and lose out on all the WSL2 benefits? :/
Hmmm, I think you're onto something, but I don't have enough experience to know what, lol.
When I do:
It works, but using this in compose (I use Portainer), I get the error shown above:
Any ideas? I'm left scratching my head here, lol.
stephen-turner commentedon Sep 16, 2020
Well, I guess so. I mean, the only options are (1) Hyper-V (2) WSL 2 but files in Windows, which has performance problems (3) WSL 2 with files in WSL 2.
I'm not sure either, but I notice something else that might be relevant. The error message referred to
/docker/DNSCrypt/dnscrypt-proxy.tomlas the file that doesn't exist. Is$HOMEperhaps blank in this context?YouveGotMeowxy commentedon Sep 22, 2020
@stephen-turner Question: when using WSL2 but keeping the files in Windows. is the performance worse than using Hyper-V with the files in Windows?
stephen-turner commentedon Sep 22, 2020
In our experiments it is worse, yes. Exactly how much worse depends on the nature of your workload: it can be anything from a few percent to multiples. The biggest penalty is when you have frequent accesses to lots of small files.
Living wholly within the WSL 2 world is always fastest, if you can achieve that.
airtonix commentedon Oct 7, 2020
btw inotify events have never worked for files stored on filesystems that come from a VMs "shared folder strategy" (it's essentially coming into your vm via Samba).
You've always had to enable some kind of polling solution like
CHOKIDAR_ENABLE_POLLING8ctopus commentedon Nov 2, 2020
I'm attaching the WSL2 issue to the thread [WSL2] File changes made by Windows apps on Windows filesystem don't trigger notifications for Linux apps
ManfredLange commentedon Nov 29, 2020
In case someone stumbles over this problem as well and isn't quite sure how to set up the dev environment with VS Code, WSL2, Docker Desktop, a dev container and a mounted directory with the cloned repo (i.e. source code), then here is an article that describes the root cause and also how to avoid it by keeping all files in the Linux file system.
I researched and wrote the article over the last few weekends and hope it'll help save you some time or at least provides some additional insights into what is happening.
"Docker Desktop on WSL2: The Problem with Mixing File Systems"
docker-robott commentedon Feb 27, 2021
Issues go stale after 90 days of inactivity.
Mark the issue as fresh with
/remove-lifecycle stalecomment.Stale issues will be closed after an additional 30 days of inactivity.
Prevent issues from auto-closing with an
/lifecycle frozencomment.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.
/lifecycle stale
docker-robott commentedon Apr 28, 2021
Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.
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.
/lifecycle locked