health check with higher rate during start_period
Description
When checking the health_check to create a dependency on container start you want to have a high rate check (like every second) to start the service as soon as possible. But once the containers are started you don't want to overload your service with health_checks.
Without this proposal, you need to wait interval time to discover your container is healthy and start the dependent containers even if the service was healthy a few seconds after being up.
I propose to have a new parameter like start_interval to override the interval period during the start_period.
Let take this config exemple:
db:
health check:
test: ...
interval: 30s
timeout: 3s
retry:2
start_period: 20s
start_interval: 1s
This will perform a health check on every 1s during the start_period (from start to healthy stat, retry limit is ignored), then perform health check on every 30s with timeout & retry applied.
This is for reducing the downtime during stack restart and avoid to overload the health test after being started.
This sounds like a nice improvement! Compose's health check support is actually a wrapper around the functionality in Docker Engine, so this would need to exist there before Compose can support it.
I would open a feature request at https://github.com/moby/moby - if/when it's included in an Engine release, we can look at extending <svc>.healthcheck in YAML accordingly.
Related;
- https://github.com/moby/moby/issues/33410
- https://github.com/moby/moby/pull/40894
With --start-interval now available could you reopen the issue? Or should it be remade?
Might as well re-open this one 👍
Next step would probably be a change in the compose-spec; there's a tracking issue in moby;
- https://github.com/moby/moby/issues/45897
And a pending PR in the compose-spec (which has to be included in compose once that's accepted/merged);
- https://github.com/compose-spec/compose-spec/pull/383
Thanks @thaJeztah 👍
This is fixed by #10939 (and also a duplicate of #10830)