Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inotifywait in docker-container doesn't register changes

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.

like image 260
Johannes Reuter Avatar asked Jan 13 '15 07:01

Johannes Reuter


People also ask

How do I increase my dev SHM in docker?

You can modify shm size by passing the optional parameter --shm-size to docker run command. The default is 64MB.

Can there be multiple Entrypoints in Dockerfile?

According to the documentation however, there must be only one ENTRYPOINT in a Dockerfile.


Video Answer


1 Answers

You have to add -mq to your script like this:

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

I have tested this solution and it works. The "m" is for "monitor" and "q" is for quiet.

like image 97
Goose Avatar answered Sep 20 '22 14:09

Goose