Reputation: 2923
According to https://docs.docker.com/engine/reference/builder/#healthcheck, we can do a health check of containers, giving them some time to boot up, set the number of retries and timeouts, etc.
The question is: is using docker container ls
to see the status of a container the only usage of this feature? I understand that it is very convenient to have a human to see if any of containers are not healthy and decide what to do with those.
Are there any consequences or custom logic in Docker deamon on how to deal with those containers that are unhealthy? Is it possible to configure it to restart those N times automatically in an attempt to bring them back to life? Or any other programmatic use?
Upvotes: 3
Views: 5082
Reputation: 263479
Docker uses the heathcheck in swarm mode, automatically replacing unhealthy containers, and slowing rolling updates to wait for a container to finish starting and become healthy before replacing other containers.
Docker compose also has some options to check the health state when deploying a multi container project with dependencies.
Beyond that, the health state is information only, shown to the user as container meta data in the container listing and inspect output. You could configure an external monitoring to detect and react to that state. However the docker engine itself will not restart unhealthy containers running outside of swarm mode.
Upvotes: 6