I recently set up healthcheck
s in my docker-compose
config.
It is doing great and I like it. Here's a typical example:
services:
app:
healthcheck:
test: curl -sS http://127.0.0.1:4000 || exit 1
interval: 5s
timeout: 3s
retries: 3
start_period: 30s
My container is quite slow to boot, hence I set up a 30 seconds start_period
.
But it doesn't really fit my expectation: I don't need check every 5 seconds, but I need to know when the container is ready for the first time as soon as possible for my orchestration, and since my start_period
is approximative, if it is not ready yet at first check, I have to wait for interval
before retry.
What I'd like to have is:
- While container is not healthy, retry every 5 seconds
- Once it is healthy, check every 1 minute
Ain't there a way to achieve this out-of-the-box with docker-compose
?
I could write a custom script to achieve this, but I'd rather have a native solution if it is possible.