2

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?

1
  • 1
    see more here: docs.docker.com/engine/reference/builder/#healthcheck it looks like the status of the health check can be viewed with docker inspect and one can query for health statuses. seems like that's all it does and you'd need to write another program to query the status and respond to health failures in various ways
    – maxm
    Jan 14, 2021 at 1:20

1 Answer 1

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.