5

I'm trying to understand how the docker compose health check options work.

healthcheck: interval: 1m30s timeout: 10s retries: 3

Would I be right in saying that this configuration will poll a container every 90 seconds, then if the container times out after 10 seconds, then the swarm will try again 3 times, after which it will mark the container for termination and create a new one to replace it

The documentation here https://docs.docker.com/compose/compose-file/compose-file-v3/

Isn't very helpful.

Thanks

h33
  • 1,104
  • 3
  • 16
  • 29

1 Answers1

13

The information is in the documentation you provided. If you follow the link and go the version 3 section about healthchecks, there it lists the properties included along with another link to the Healthcheck Dockerfile instruction. There it describes the settings in your question in detail.

Interval

The health check will first run interval seconds after the container is started, and then again interval seconds after each previous check completes.

Timeout

If a single run of the check takes longer than timeout seconds then the check is considered to have failed.

Retries

It takes retries consecutive failures of the health check for the container to be considered unhealthy.

An unhealthy docker image is not going to restart by itself it's just marked as unhealthy. It's up to you to add actions to take when an instance is marked this way.

DomRow
  • 169
  • 3
  • 12