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 · 43 comments

Comments

@DeltaWhy
Copy link

commented Aug 24, 2016

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Aug 24, 2016

@friism adding it now to the FAQs

@rn

This comment has been minimized.

Copy link
Contributor

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 Aug 25, 2016

@garveen

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

commented Aug 30, 2016

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

@rn

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Sep 13, 2016

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

@DeltaWhy

This comment has been minimized.

Copy link
Author

commented Sep 13, 2016

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

This comment has been minimized.

Copy link

commented Oct 18, 2016

This hurts too much for beeing closed.

@frankgreco

This comment has been minimized.

Copy link

commented Nov 1, 2016

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

This comment has been minimized.

Copy link

commented Nov 3, 2016

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

This comment has been minimized.

Copy link

commented Nov 3, 2016

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Dec 6, 2016

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link

commented Dec 6, 2016

@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Dec 6, 2016

@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

This comment has been minimized.

Copy link

commented Jan 19, 2017

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.

@lightrow

This comment has been minimized.

Copy link

commented Feb 1, 2018

why is this issue closed? It still doesn't work, even with LCOW on latest 18.02.0 version, and im still forced to use dirty workarounds

@wgwz

This comment has been minimized.

Copy link

commented Mar 20, 2018

Just for anyone else who ever runs into this, I followed the hint in this comment:

I don't want to use polling

And I started using polling :D
It works for me so far.

Running this in the container with volume mounted src, detects changes and reloads OK:

webpack --config webpack.debug.js --watch --watch-poll 1

Win10, source code volume mounted into the container like so:

  watch:
    build:
      context: .
      dockerfile: Dockerfile.local
    volumes:
     - .:/usr/src/app
    command: ['bash']
@wintercounter

This comment has been minimized.

Copy link

commented Jun 11, 2018

This really helped me too, worked like a charm: #56 (comment)
Guys, please add such support into Docker until there's a final solution, shouldn't be that hard, blog also tells what they're exactly doing.

@nemzes

This comment has been minimized.

Copy link

commented Jun 12, 2018

Another workaround that seems to do the job (from WSL too): https://github.com/FrodeHus/docker-windows-volume-watcher/releases

openfirmware added a commit to GeoSensorWebLab/D162-WMS that referenced this issue Aug 13, 2018
Add note about container updates on Windows
See issue: docker/for-win#56
Users must manually reload kosmtik as file system events are not
propagated from the Windows host into the container properly.
@iki

This comment has been minimized.

Copy link

commented Dec 2, 2018

The @merofeev docker-windows-volume-watcher in python mentioned by @therealmikz works perfectly. If you prefer go, there's also @FrodeHus docker-windows-volume-watcher in go mentioned by @nemzes.

In our case, I didn't use the common watchmedo command from @gorakhargosh python watchdog package, because it was too fast and restarted the service in docker several times on each change. Instead, I picked inotifywait from @rvoicilas inotifytools, and put sleep there. The Attrib events need to be monitored in this case, because the docker-windows-volume-watcher in python rewrites file permissions to trigger inotify. Also, you need to apt-get install inotify-tools in the Dockerfile, and it's helpful to know the trick to use inotifywait exclude regexp to actually only include particular extension.

This is how we use it in Makefile.

  • make run runs the service (inside docker container)
  • make dev runs the service and reloads on code change (inside docker container)
  • make start starts the docker container, and if run on Windows it also waits 10s and runs the volume watcher on background
PROJECT = project-name
CODE_DIR ?= src

run:
	# Starting local service...
	cd $(CODE_DIR) && python service.py

run-detached:
	make run &

dev:
	# Starting local service in development mode (will reload on code change)...
	@while true; do \
	  make run-detached; \
	  inotifywait -e create -e modify -e delete -e move -e attrib -r $(CODE_DIR) --exclude '[^.]..$$|[^p].$$|[^y]$$'; \
	  pkill -exf 'python service.py'; \
	  sleep 1; \
	done

watcher:
	@if [ "$(OS)" = 'Windows_NT' ]; then if where docker-volume-watcher >/dev/null 2>&1; then \
          sleep 10; \
	  echo "# Starting Docker volume watcher for Windows to enable reloading on code change..."; \
	  echo "# See https://github.com/docker/for-win/issues/56"; \
	  docker-volume-watcher '$(PROJECT)_*' 2>&1 | grep -v 'ERROR:root:Exec run returned non-zero exit code: 1'; \
	else \
	  echo "# Install Docker volume watcher for Windows to enable reloading on code change..."; \
	  echo "# > pip install docker-windows-volume-watcher"; \
	fi; fi

start:
	make watcher &
	# Starting containers...
	docker-compose -p $(PROJECT) up
@jasonwilliams

This comment has been minimized.

Copy link

commented Jan 5, 2019

Does anyone know why this is closed? from what i understand the Docker Guest still isn't notified when i change a file on a windows host. @iki @friism ?

We use Webpack.
Polling is not an option here as it causes our CPU to go mental and on MacOS host its not needed.

@TheKnightCoder

This comment has been minimized.

Copy link

commented Jan 20, 2019

I think running the docker engine on WSL could be a potential solution for this problem. WSL supports Inotify.
Have a look at this thread microsoft/WSL#2291

@cpu100

This comment has been minimized.

Copy link

commented Feb 23, 2019

docker-machine ssh default touch /path/to/file/under/shared/folder

@zippoxer

This comment has been minimized.

Copy link

commented Feb 26, 2019

If anyone's interested, I've forked docker-windows-volume-watcher and made many improvements: https://github.com/zippoxer/docker-windows-volume-watcher

I made it almost 2x faster, added -ignore, added -delay (default 100ms) to accommodate the way editors save files, and fixed some bugs.

I hope this helps someone ;-)

(Still disappointed to see the problem hasn't been fixed yet for over two years now..)

@peteromano

This comment has been minimized.

Copy link

commented Mar 10, 2019

@zippoxer Exactly. i havent gotten "dwvm" to work yet, but yes, i was gonna comment the same thing - why is this still an issue??

Ill try your fork btw instead. (i didnt spend much time on trying dwvm yet, but so far, im getting "no container found" errors.) its probably just something on my end tho

@Lukortech

This comment has been minimized.

Copy link

commented Aug 19, 2019

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

This comment has been minimized.

Copy link

commented Aug 19, 2019

@PieterScheffers

This comment has been minimized.

Copy link

commented Aug 19, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.