15

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.

4

2 回答 2

1

您必须像这样将 -mq 添加到您的脚本中:

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

我已经测试了这个解决方案并且它有效。“m”代表“监控”,“q”代表安静。

于 2021-07-02T13:27:49.373 回答
-1

我有类似的问题 - 在 docker 容器内缺少 inotify 通知,结果发现问题在于将别名文件夹安装为卷,在将主机文件夹替换为实际目录后,一切都开始工作了。

在我的情况下,它是 OS X 上的 /tmp,因此在将其替换为/private/tmp:/tmp容器后开始接收 inotify 事件。

于 2020-06-19T14:05:02.953 回答