Restarting an unhealthy docker container based on healthcheck

前端 未结 6 935
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 16:31

I am using Docker version 17.09.0-ce, and I see that containers are marked as unhealthy. Is there an option to get the container restart instead of keeping the cont

6条回答
  •  有刺的猬
    2021-01-30 16:36

    According to https://codeblog.dotsandbrackets.com/docker-health-check/

    Create container and add " restart: always".

    In the use of healthcheck, pay attention to the following points:

    For standalone containers, Docker does not have native integration to restart the container on health check failure though we can achieve the same using Docker events and a script. Health check is better integrated with Swarm. With health check integrated to Swarm, when a container in a service is unhealthy, Swarm automatically shuts down the unhealthy container and starts a new container to maintain the container count as specified in the replica count of a service.

提交回复
热议问题