inotifywait in docker-container doesn't regist

2019-06-16 19:55发布

问题:

I have a script running inside a docker-container which listens for changes in a directory via inotifywait. The directory is mounted to the host-system via docker -v.

For some reason, inotifywait doesn't get triggered when files inside this directory is changed.

This is the problematic script-line

inotifywait -e create -e modify -e delete -e move  /etc/nginx/sites-enabled

The container is started like this (via fig)

web:
  build: .
  ports:
   - "80:80"
  volumes:
   - ./conf:/etc/nginx/sites-enabled

When I start the setup via fig up, the script is executed, but changes in the mounted volume don't trigger the inotify-barrier.

回答1:

(Just because I saw boot2docker tag) Are you sure your container can see the file changed ? If you wrote on your host, it will be an inotify event on your mac, not on the VM that runs docker daemon.

TL;DR : boot2docker ssh touch /file/on/mounted/volume