Docker Windows Volume Watcher
This script monitors directory bindings of Docker containers on Windows hosts and notifies containers about file changes.
The script aims to be workaround for the problem of file change events propagation on Windows hosts. Due to limitations of CIFS implementation in Linux kernel, file change events in mounted folders of host are not propagated to container by Docker for Windows. This problem renders watch mode of modern frameworks (e.g. Jekyll, ng-cli, etc.) development servers useless, since containers are not notified about file changes. This problem is described on Docker Community Forums.
This script can be installed with pip (both Python 2 & 3 are supported).
pip install docker-windows-volume-watcher
Monitor all directory bindings of all containers. The script will listen for container start/stop events and notify all running containers about file changes.
Monitor only bindings of container
Monitor only binding of
container_name to host directory
docker-volume-watcher container_name C:\some\directory
You can also specify wildcards with
? characters. For example: monitor only bindings of containers with names containing myproject to directories starting with
docker-volume-watcher *myproject* C:\project\folder\*
Do not monitor files/directories matching
docker-volume-watcher -e "*.git*" "*build*"
-v to enable verbose output: the script will report start/stop events of eligible containers and print all detected file changes.
- The script doesn't propagate to container file deletion events.
- The script requires
chmodutils to be installed in container (this should be true by default for the most of containers).
The script uses
watchdog package to observe file change events of the host directory. Once file change event is fired the script reads file permissions of changed file (using stat util) and rewrites file permissions with the same value (using
chmod util) thus triggering inotify event inside container.
"Rewrite file permissions approach" was used instead of updating file last modified time with
touch util. Since touching will cause event loop: touch will trigger file change event in Windows, script will handle this event and touch file again, etc.