Reputation: 13691
This is my mvp docker-compose.yml:
version: '2.4'
services:
first:
image: alpine:latest
entrypoint: sleep 100s
healthcheck:
test: sleep 1
timeout: 2s
start_period: 1s
second:
image: alpine:latest
entrypoint: sleep 10s
depends_on:
first:
condition: service_healthy
What I'd expect to happen:
test sleep 1
should return, turning the service healthyHowever what happens:
Where is my misconception that explains this huge difference?
(I don't want a discussion, on weather having healthchecks and depends_on conditions are good practice ore not. That would not be on topic for this question)
Upvotes: 3
Views: 3398
Reputation: 13691
The misconception is:
The default value for the parameter interval
is 30s
.
And though the parameter start_period
might suggest something different, the first health check is performed after that interval.
The start_period
does not demark the time, the healthchecks start but instead the time, negative results would be considered not fatal.
Therefore it is impossible to define a sensible waiting time for the first health_check without providing unsensible intervals, the check is rerun during the whole life time.
Upvotes: 4