File system watch does not work with mounted volumes

Awesome work, thank you @merofeev, you’re a hero! I can confirm that docker-volume-watcher (github) works perfectly on Windows 10 (Docker Toolbox w/ VirtualBox) with an alpine docker container (node:6.17-alpine in my case). This is the best solution; use native inotify file notification events in Linux and then ensure your libraries or build scripts (e.g. gulp) are not using polling at all. The end result is essentially 0% CPU usage vs. 30% CPU load (I’ve got a large number of files to monitor).

Note: From my research, I found that if you’re using grunt (with grunt-watch-contrib like I am) it will not appear to work, because no matter what, it’ll actually be using polling via node’s older fs.watchFile() API. So ensure you’re using a library like chokidar and after it indexes all the files you want to watch, it should sit fully idle and docker-volume-watcher will dutifully notify chokidar in your container using inotify!

EDIT: There does appear to be one limitation, which is that docker-volume-watcher isn’t capable of notifying about file deletion, which could be a potential problem for some. I’ve added an issue about that here: https://github.com/merofeev/docker-windows-volume-watcher/issues/16

I get an error when I try to run docker-volume-watcher

ImportError: No module named pywintypes

And going down the google hole has gotten me nowhere. Every suggestion is dated from 2017 and nothing has worked.

Any suggestions?

note that the mounted volume must not be read-only

WSL2 does not solve this problem.

In case it helps anyone in the future, sometimes applications that watch for file system changes implement a “poll” feature which will “check” for file changes every couple of seconds.

I ran into this issue a month ago, so I don’t specifically recall what application I was using.

Here is an example of polling in nodemon.

Look for this functionality in your package you’re using, at least until file system watch will work with mounted volumes in WSL!