# 以下是不会重新启动的容器,为空则所有的stop的容器都会start，每个容器名用空格隔开
docker_restart_name=()


docker_name=`docker ps -a --format "{{.Names}}"`

if [[ "$?" != 0 ]] ; then
   time=$(date "+%Y-%m-%d %H:%M:%S")
   echo $time “重新启动了docker service” >> check_docker_service.log
   service docker start

   docker_name=`docker ps -a --format "{{.Names}}"`
   for each in $docker_name;
   do
      if [[ "${docker_restart_name[@]}" =~ $each ]] ; then

         echo $each "不需要重启"
      else

         docker start $each
      fi
   
   done
else

   docker_name=`docker ps -a --format "{{.Names}}"`
   for each in $docker_name;
   do
      if [[ "${docker_restart_name[@]}" =~ $each ]] ; then

         echo $each "不需要重启"
      else

         docker start $each
      fi

   done
fi