Docker Community Forums

Share and learn in the Docker community.

Pyinotify stops working on particular folder after some time

beta

(Scarlac) #1

Expected behavior

Docker triggers file system changes for shared volumes from the host to containers. This enables a Django development server to pick up file system changes (and reload itself) using pyinotify and avoid polling for changes.

Actual behavior

Sometimes Docker for Mac will stop sending file modification and creation events to the containers for particular folders. Once it stops working, restarting Docker for Mac and down’ing the containers and re-up’ing them will not alleviate the problem. It may be possible to fix by restarting the host.

(I use “Sometimes” to describe the occurrence of the problem since I am not entirely sure how to put my host machine into this problem state. I have a faint idea that it’s related to suspend/resume or updating Docker for Mac)

Information

$ pinata diagnose -u

OS X: version 10.11.5 (build: 15F34)
Docker.app: version v1.11.1-beta13.1
Running diagnostic tests:
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Docker logs are being collected into /tmp/20160530-115941.tar.gz
Most specific failure is: No error was detected
Your unique id is: 647DEBCA-EDD8-4521-AE4D-1D65C342D1A8
Please quote this in all correspondence.

host distribution and version ( OSX 10.10.x, OSX 10.11.x, Windows, etc ):
I am running OS X 10.11.5 (15F34), Docker for Mac v1.11.1-beta13.1 (build: 8193).
Bug has been around at least since Docker for Mac Beta11

Steps to reproduce the behavior

  1. docker run --rm -it -v "$PWD":/code python:alpine ash
  2. pip install pyinotify
  3. python -m pyinotify -v /code

[2016-05-30 10:05:45,272 pyinotify DEBUG] Start monitoring [’/code’], (press c^c to halt pyinotify)
[2016-05-30 10:05:45,273 pyinotify DEBUG] New <Watch wd=1 path=/code mask=4095 proc_fun=None auto_add=None exclude_filter=<function WatchManager. at 0x7f1458c98488> dir=True >

Now, outside the container, in the shared directory, run this:

  1. echo "foo" > foo.txt

It should output this:

[2016-05-30 10:05:56,509 pyinotify DEBUG] Event queue size: 32
[2016-05-30 10:05:56,510 pyinotify DEBUG] <_RawEvent cookie=0 mask=0x100 name=foo.txt wd=1 >

[2016-05-30 10:05:56,511 pyinotify DEBUG] Event queue size: 32

But instead I am not getting any extra output.

While writing the this report I actually had it working in a different folder than the project I am working on. It seems that my specific project folder is broken and neither removing the containers involved or restarting Docker fixes it. The particular folder and all changes within it are just not registered by pyinotify.

TLDR Screenshot:

Edit: I just found a strange workaround: Stopping the container, renaming the problematic folder to something else, and renaming it back to the original name seems to have solved the issue temporarily so the container now again receives notifications from the problem folder.