1、swarm 集群模式

docker service create --name container_name \
       --health-cmd "curl    || exit 1" \
       --health-interval=5s \ 两次健康检查的间隔,默认为 30 秒
       --health-retries=12 \  当连续失败指定次数后,则将容器状态视为 unhealthy,默认 3 次
       --health-timeout=2s \ 健康检查命令运行超时时间,如果超过这个时间,本次健康检查就被视为失败,默认 30 秒
       --start-period=60s \ 应用的启动的初始化时间,在启动过程中的健康检查失效不会计入,默认 0 秒
       imagename
2、单机启动模式
docker run  -d --net=host  --name container_name \
       --health-cmd "curl    || exit 1" \
       --health-interval=5s \ 两次健康检查的间隔,默认为 30 秒
       --health-retries=12 \  当连续失败指定次数后,则将容器状态视为 unhealthy,默认 3 次
       --health-timeout=2s \ 健康检查命令运行超时时间,如果超过这个时间,本次健康检查就被视为失败,默认 30 秒
       --start-period=60s \ 应用的启动的初始化时间,在启动过程中的健康检查失效不会计入,默认 0 秒
       imagename