监控docker容器运行状态 shell 脚本
跳转到导航
跳转到搜索
脚本
# cat mon_docker.sh
#!/bin/bash
containerName=$1
currTime=`date +"%Y-%m-%d %H:%M:%S"`
exist=`docker inspect --format '{{.State.Running}}' ${containerName}`
if [ "${exist}" != "true" ]; then
docker restart ${containerName}
echo "${currTime} 重启docker容器,容器名称:${containerName}" >> /opt/docker.log
fi
定时任务crontab
*/10 * * * * /opt/mon_docker.sh 55fdedd6beaa