brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: HEALTHCHECK --start-interval checks a starting Docker container more often

Docker
~/tips/tip-docker-healthcheck-start-interval

HEALTHCHECK --interval=30s --start-period=60s --start-interval=5s \

Lets a slow-starting container report healthy sooner by probing more often during startup.

A container with a health check every 30 seconds can sit in “starting” for half a minute after it is ready. Anything that waits for it to be healthy waits too. Docker has an option just for the startup phase.

HEALTHCHECK --interval=30s --start-period=60s --start-interval=5s \
  CMD curl -fs http://localhost:8080/health || exit 1

--start-period is a grace period after the container starts. Failed checks during that time do not count towards the retries, so a slow app is not marked unhealthy while it is still booting. --start-interval is the time between checks during that start period. So here Docker checks every 5 seconds for the first minute, and then every 30 seconds.

The docs add one more detail I like: if a check succeeds during the start period, the container counts as started, and from then on the normal interval applies.

The defaults, for reference: interval 30s, timeout 30s, start period 0s, start interval 5s, retries 3.

Caveat: --start-interval needs Docker Engine 25.0 or later, according to the Dockerfile reference. On an older engine, check your version with docker version before you rely on it. Also keep the check itself light. A health check that runs every 5 seconds should not be a heavy database query.

Further reading: Dockerfile reference: HEALTHCHECK

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link