Monitoring file changes in Docker volumes

前端 未结 1 812
忘掉有多难
忘掉有多难 2021-01-04 05:57

I have a docker container that is running a python script: waiting for input requests and processing data accordingly.

Since I am using docker for development,

相关标签:
1条回答
  • 2021-01-04 06:12

    You could have your container run something like this ( need inotify installed ):

    while true
    do
            inotifywait -e create -e modify  /path/to/python/script
            pkill python
            python /path/to/python/script
    done
    

    Basically wait for changes on the file, kill python on the machine, run script again. If the python script is not running in the background/deamonized in any way you could use an & like so: the python /path/to/python/script &

    Put this into run.sh, add something like this to your Dockerfile

    COPY run.sh /run.sh
    CMD ["bash", "-l", "/run.sh"]
    

    ... and you should be good.

    0 讨论(0)
提交回复
热议问题