Tag: suricata

反馈请求 – 在文件更改时重新启动Docker容器

我有这个工作,但想知道是否有任何潜在的副作用,甚至更好的方式来做到这一点。 下面的例子是通用的。 我有一个docker-compose文件,包含两个容器( container_1和container_2 )。 container_1公开了一个卷,其中包含用于运行已安装服务的各种configuration文件。 container_2从container_2安装卷,并定期运行一个脚本,用于提取文件并更新container_1运行的服务的configuration。 每次configuration更新时,我都想重新启动container_1的服务,而不必使用cron或我已经讨论过的其他一些方法。 我的解决scheme 我在container_1上放了一个脚本,检查configuration文件是否已经更新(文件最初是空的,md5sum存储在一个单独的文件中),如果文件已经根据md5sum进行了更改,它会更新当前散列并杀死进程。 在撰写文件中,我有一个healthcheck ,定期运行脚本,并restart设置为always 。 当container_2的脚本运行并更新container_2的configuration文件monitor_configs.sh , container_1上的脚本将monitor_configs.sh该服务的进程,容器将重新启动并重新加载configuration。 monitor_config.sh # current_hash contains md5sum of empty file initially #!/bin/sh echo "Checking if config has updated" config_hash=$(md5sum /path/to/config_file) current_hash=$(cat /path/to/current_file_hash) if [ "$rules_hash" != "$current_hash" ] then echo "config has been updated, restarting service" md5sum /path/to/config_file > /path/to/current_file_hash kill […]