🐳 Fix a Healthcheck Interval Too Slow to Catch a Crash Loop
A HEALTHCHECK instruction only gets as many chances to notice trouble as its –interval and –retries allow, and those two numbers compound: an interval of 30 seconds with three retries means a container can be failing for a full 90 seconds or more before Docker ever marks it unhealthy. If the process inside the container has its own internal supervisor quietly restarting a crashing worker thread or sub-process every few seconds, that whole crash loop can run invisibly under the healthcheck’s radar, because by the time three slow checks finally land on a failure, the internal supervisor has already restarted it again and the next check passes.
🔎 The Problem
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ CMD curl -f http://localhost:8080/health || exit 1 # App's own process supervisor restarts a crashed worker every ~8 seconds. # A 30s-interval check has a good chance of landing right after a restart, # seeing a healthy response, and never accumulating 3 consecutive failures - # the crash loop runs the entire time the container is "healthy"
✅ Fix: A Healthcheck Interval Too Slow to Catch a Crash Loop
- Shorten –interval to match how quickly the thing you actually care about can fail and recover, not just a comfortable default, especially for a process with its own internal restart behavior.
- Add a separate counter or last-crash-timestamp endpoint the healthcheck can query, so a container that’s technically responding right now but has crashed five times in the last minute still gets reported as unhealthy.
- Pair the Docker-level healthcheck with application-level crash-loop logging, since a fast enough interval only catches it if the check happens to land during the down window in the first place.
🚨 Why This Is Dangerous
- A container that looks healthy to Docker while silently crash-looping underneath can stay in production serving degraded or inconsistent responses far longer than anyone watching the orchestrator’s status would expect.
A healthcheck’s interval isn’t just a polling frequency — it’s the size of the blind spot between one look and the next.




