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

Inotify on shared drives does not work #56

Closed
DeltaWhy opened this issue Aug 24, 2016 · 58 comments
Closed

Inotify on shared drives does not work #56

DeltaWhy opened this issue Aug 24, 2016 · 58 comments

Comments

@DeltaWhy
Copy link

I'm using docker-compose to run a Node.js application with nodemon. The application source is on the Windows host and mounted on the container so that I can make changes without rebuilding. However, nodemon does not pick up file changes. If I exec a shell inside the container and touch one of the files from there, nodemon picks it up and restarts the app, but any changes from Windows don't seem to trigger the inotify events.

@friism
Copy link

friism commented Aug 24, 2016

@DeltaWhy thanks, this is a known limitation that we're trying to figure out how to address.

nodemon has a fallback polling mode that I recommend you try: https://github.com/remy/nodemon#application-isnt-restarting

@londoncalling I checked the FAQ, and it looks like we don't have a mention that inotify doesn't work on Windows - it might be good to add.

@londoncalling
Copy link

@friism adding it now to the FAQs

@rn
Copy link
Contributor

rn commented Aug 25, 2016

@DeltaWhy We are using SMB for the file sharing and the Linux SMB implementation does not support change notifications. We have update the FAQ accordingly andI'm closing this issues.
Thanks for reporting

@rn rn closed this as completed Aug 25, 2016
@garveen
Copy link

garveen commented Aug 30, 2016

https://wiki.samba.org/index.php/Samba_3.0_Features_added/changed

Samba 3.0.25:

New file change notify subsystem which is able to make use of inotify on Linux.

@rn
Copy link
Contributor

rn commented Aug 30, 2016

@garveen unfortunately, the linux kernel implementation of SMB (in ./fs/cifs) does not support inotify. There are various comments in the code that the older dnotify once was supported (and it is marked as experimental) but none of the code calls into the fsnotify API.

UPDATE: I think the above refers to the Linux SMB server being able to generate SMB change notification from inotify events. The opposite direction is what is needed by Docker for Windows: SMB change notifications generated by the server on the host need to be translated into the events on Linux

@garveen
Copy link

garveen commented Aug 30, 2016

@rneugeba maybe other than smb:

If we have a tool that listen on native Windows' file system APIs, communicate with MobyLinux and generate Linux events, it would be great.

Does this idea practicable?

@DeltaWhy
Copy link
Author

I assume Hyper-V doesn't have anything akin to VirtualBox shared folders? Inotify works great with Docker Toolbox as well as Vagrant.

@rn
Copy link
Contributor

rn commented Sep 1, 2016

@DeltaWhy I haven't seen anything in the VBox source suggesting they support inotify on the shared folders, but I may have looked at the wrong place, but there seems plenty of evidence on the web that it doesn't, like for example: https://www.virtualbox.org/ticket/10660?cversion=0&cnum_hist=1

@kidlj
Copy link

kidlj commented Sep 11, 2016

@rneugeba @friism
Vagrant can make bi-directional file changes synchronization between Windows host and Linux guest machines. And Vagrant takes several ways to achieve this:

SMB: https://www.vagrantup.com/docs/synced-folders/smb.html
RSync: https://www.vagrantup.com/docs/synced-folders/rsync.html
Virtualbox shared folders: https://www.vagrantup.com/docs/synced-folders/virtualbox.html

Hope you can get some inspirations from there! Thank you D4W developers.

@friism
Copy link

friism commented Sep 12, 2016

@kidlj yes, moving files and file changes back and forth works fine (as it does with Docker for Windows), but the inotify change notifications are not, and not with any of those solutions that you linked to either, at least not that I know of. Do you have an example of inotify working with either SMB, RSync or vbox shared folders?

@kidlj
Copy link

kidlj commented Sep 13, 2016

@friism Thank you for the explanation. I thought inotify was the same as file changes synchronization, but now I get it.

I just found a vagrant solution for the same inotify issue, could it help?
https://github.com/adrienkohlbecker/vagrant-fsnotify

@friism
Copy link

friism commented Sep 13, 2016

@kidlj I don't think it works for Windows, but might be an interesting model. Maybe @rneugeba has thoughts.

@DeltaWhy
Copy link
Author

I guess I was mistaken. It looks like mocha --watch works on both (I guess it's using polling) and nodemon doesn't by default, which is maybe why I got confused.

Rsync with rsync-auto should trigger inotify events since it's touching files on the Linux native FS, right? But that probably won't work for sharing a whole drive 😉

Vagrant-fsnotify looks very interesting but I wonder if that approach would also have performance issues when sharing a whole drive. You might need a Linux kernel module to tell what's being watched on the CIFS mount so the host side can watch those same things rather than the whole drive.

@blaggacao
Copy link

This hurts too much for beeing closed.

@frankgreco
Copy link

Why is this issue closed? I want to use Docker Native for local development across my entire organization but can't util inotify works for windows as well. I don't want to use polling because I want seamless integration between windows/mac code bases and don't want to change my webpack config files for example to use polling if you have a windows machine.

Is there someplace for this feature/enhancement can be tracked so I know that status of it.

@blaggacao
Copy link

I guess strategic bets are to wait for windows linux subsystem. But some cracky C# person wouldn't be that limited as most of us to fix this in upstream samba quickly.

@frankgreco
Copy link

It would be nice if there was a Docker Native backlog that I could refer to so that I know when Docker is planning on address this (they say they will eventually as they want Docker for Mac/Windows to be the same). That way, I'd have an idea on when I can plan on having this implemented in my organization.

@friism
Copy link

friism commented Nov 6, 2016

[..] C# person wouldn't be that limited as most of us to fix this in upstream samba quickly

@blaggacao Samba is implemented in C: https://github.com/samba-team/samba

@asolopovas
Copy link

It looks like issue is so difficult to implement that developers don't even want to talk about it, that's why it gets closed without even discussing it.

@rn
Copy link
Contributor

rn commented Dec 6, 2016

@asolopovas

  • To implement this correctly with SMB/CIFS requires significant changes to the generic Linux Virtual Filesystem layer, not just improvements to the Linux Kernel SMB implementation.
  • Another option is to go the route we have taken with Docker for Mac, which uses a user-space file system (FUSE) in Linux and then passes this to a daemon on the host which implements the requires semantics. This requires mapping of Linux filesystem semantics (including users, permissions, symlinks, inotify etc) to NTFS filesystem semantics. The filesystems are very different and it's not possible in all cases to map the semantics. WSL helps a little bit, but it too has mis-matched semantics.
  • The other "solutions" mentioned in this thread all seem like hacks which come with fairly big caveats, so they may work in one case but maybe problematic in others.

@frankgreco
Copy link

@rneugeba Is Docker planning on implementing this? Here is says, "Currently, inotify does not work on Docker for Windows. This will become evident, for example, when an application needs to read/write to a container across a mounted drive. This is a known issue that the team is working on."

Is there an estimated time for this functionality being available? Or, is there somewhere on the Docker Github where future/current work like this is officially proposed/tracked?

@friism
Copy link

friism commented Dec 6, 2016

@frankgreco I've sent a PR to update the docs. As @rneugeba pointed out, we don't have a lot of good options at the moment. We're aware that this is an annoying limitation, and we're continuously evaluating progress in WSL and Samba to see what improvements we might incorporate.

@frankgreco @asolopovas what programming framework are you using? Does it not have a polling mode for looking for filesystem changes, similar to nodemon?

@asolopovas
Copy link

@friism I am using browsersync haven't found any polling modes in it but was searching for. I know that webpack has it but I use combination of browsersync with webpack and hot module reload and it does not seem to work if I enable poling just in webpack. I simply installed all necessary tools on my host so that I can operate looks like we just have to be a bit more patient.

@trodrigues
Copy link

I know +1s in issue comments don't help but I'd just like to add my voice here and say this is an issue that I also care about very much and would love to see it addressed in the future. In fact, I found this issue here today because I saw this was an issue a few months ago and decided to come back and look for what the current status of this situation was.

@Lukortech
Copy link

Hello everyone!
I am writing here since there was no better place yet to be found.
I am using Win10.pro with Docker, but it seems that there are no changes seen by webpack too, and I don't understand why won't my front-end env. refresh after changes to the .ts files of any sort.

I've looked for any kind of help and it al lbrought me here. Waiting for an update. Hopefully windows users won't be second-class citiziens soon.

@wintercounter
Copy link

wintercounter commented Aug 19, 2019 via email

@PieterScheffers
Copy link

Docker already has a Tech preview out. https://blog.docker.com/2019/07/docker-wsl2-tech-preview/

@mastacheata
Copy link

Does anyone yet have any results with Docker Desktop Community 2.1.6.0/2.1.6.1 which should've fixed this problem?
I tried, but without any success.
Quite the opposite, actually. It seems that the container is now unaware of inotify events inside it's own filesystem as well and no longer just forgets to broadcast the events to the containers. (volume watcher tools as well as touching/chmoding a file from docker exec seem to have no effect on either python or node's file-watchers. :(

@djs55
Copy link

djs55 commented Nov 26, 2019

@mastacheata thanks for your port. Could you try the following on the latest edge release:

  • create a directory for testing
  • share the directory with docker run -it -v <path>:/foo djs55/inotify-event --dir /foo
  • create a subdirectory on the host inside the testing directory

If the inotify event injection is working then you should see events inside the docker run like this:

watch=1 cookie=0 events=CREATE "foo"

Here's a screen capture of it working locally for me: https://youtu.be/M6lpN65yF38

@amd5 amd5 mentioned this issue Dec 3, 2019
@scottkurz
Copy link

scottkurz commented Dec 5, 2019

@djs55 thx for the instructions... I tried your inotify-event image with the edge Docker Desktop v2.1.6.1 and saw nothing happened when creating a subdir from the host with PS, Win Explorer, etc. Would be happy to try something else.

@mastacheata
Copy link

mastacheata commented Dec 5, 2019

Same here (Docker Desktop 2.1.6.1 Build 40900, Docker Engine 19.03.5):

λ  docker run -it -v C:\Users\benedikt\foo:/foo djs55/inotify-event --dir /foo
Unable to find image 'djs55/inotify-event:latest' locally
latest: Pulling from djs55/inotify-event
7622164d525b: Pull complete
Digest: sha256:ce5540b724b37808d8933f80cf393e07bcb0a9e865891aa4e75786d8b316f67c
Status: Downloaded newer image for djs55/inotify-event:latest

And that's it. No more output from the container after that when creating directories inside the mounted directory.

https://youtu.be/PI-u1YO3pfY

@francescobianco
Copy link

@DeltaWhy @friism @scottkurz My solution is create a clone of INOTIFYWAIT full bash based on polling using a diff screenshot of filesystem, please take a look and support it work perfect on WINDOWS systems
https://github.com/javanile/inotifywait-polling

@mastacheata
Copy link

@DeltaWhy @friism @scottkurz My solution is create a clone of INOTIFYWAIT full bash based on polling using a diff screenshot of filesystem, please take a look and support it work perfect on WINDOWS systems
https://github.com/javanile/inotifywait-polling

Well, there are already 4-5 different versions of that. They all have downsides like not being able to transfer permission changes back and forth.

Docker Desktop on WSL2 officially supports inotify events on mounted volumes. It's just not working for me or @scottkurz ☹️

@scottkurz
Copy link

To clarify I'm not using WSL2 (or WSL).

@mastacheata
Copy link

To clarify I'm not using WSL2 (or WSL).

Well, than nothing is supposed to change. The inotify fix was only announced for docker running in WSL2 mode.

@francescobianco
Copy link

@mastacheata please could you link example of this

Well, there are already 4-5 different versions of that.

@djs55
Copy link

djs55 commented Dec 16, 2019

The latest edge release of Docker Desktop (2.1.7.0) should have better support for inotify on shared drives (in regular Linux mode, not WSL2) -- It's worth trying if you have the time. There is a known bug when used with docker-compose, see #5318 (comment) for a workaround.

@mastacheata
Copy link

@mastacheata please could you link example of this

Well, there are already 4-5 different versions of that.

And of course all the forks of each.
They basically watch Windows for changes and then change the permissions using docker exec of those files that changed in order to trigger a proper inotify event without changing the dates of the file (previous tooling used to do this by issueing a touch command inside the container, which would cause unwanted side effects)

@kamko
Copy link

kamko commented Jan 21, 2020

The support for inotify that @djs55 mentioned in edge release is now in latest (2.2.0.0) stable release

Docker Desktop now supports inotify events on shared filesystems.
https://docs.docker.com/docker-for-windows/release-notes/#docker-desktop-community-2200

@djs55
Copy link

djs55 commented Jan 21, 2020

I hope the inotify support works for you!

If not, please repro the problem (e.g. change a file on the host), capture a diagnostics and make a fresh ticket.

@madacol
Copy link

madacol commented Jan 21, 2020

How lucky of me!!!
I encounter this bug today and hours later its fixed with the update.

I had the same problem as OP.
A NodeJs app with nodemon, using docker-compose

@docker-robott
Copy link
Collaborator

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

@docker docker locked and limited conversation to collaborators Jun 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests