Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose healthcheck options

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

like image 740
h33 Avatar asked Jan 23 '26 00:01

h33


1 Answers

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.

like image 72
DomRow Avatar answered Jan 25 '26 19:01

DomRow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!