I have been searching for a few hours and can't seem to find the most current answer to this problem
Problem: Apparently VirtualBox is being used by Docker on MacOS and it does not want to pass file notifications from the Host OS to the container. As a result, inotifywait will only notify file activity on a watched folder when those actions are performed from within the container. NOT when those actions are performed from the Host.
Dockerfile
FROM python:3.9.6
COPY main.sh /bin/main.sh
RUN chmod +x /bin/main.sh
RUN apt-get update -y
RUN apt-get install -y inotify-tools
CMD /bin/main.sh
main.sh
#!/usr/bin/env bash
inotifywait -mq -r -e create -e modify -e delete -e move /data |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'" >> log.txt
done
build the container
docker build -f Dockerfile -t my_container .
run the container
docker run -it -v /someHOSTdirectory/data:/data my_container my_container
the log.txt file is created and has lines for any actions in the watchfolder that were initiated from within the container shell. But NOT if the action is performed from the Host on this mounted volume
I am using a python base image because I have a python script that I want to run on any new file that comes into that watchfolder or its subdirectories. This docker container will run on my debian server, but I'm developing on a mac.