Health check marks a container unhealthy but nothing restarts it.
IntermediateScenarioLimits, logging, health checks and restarts
Answer
Situation read → Plain Docker only labels health; it doesn't act on it.
What I'd do → Use Swarm (restarts unhealthy tasks), Kubernetes probes, or a watcher such as autoheal container, or systemd Restart= plus docker kill hooks. Compose depends_on: condition: service_healthy uses it for ordering only.
Why → The engine records state healthy/unhealthy for orchestrators to use.
Interview tip → This is a classic trick question.
More on Limits, logging, health checks and restarts
A Java container is OOM-killed at 512 MB. Why isn't the heap the whole story?IntermediateHow do you cap CPU and memory for a container and what happens on exceed?BeginnerLatency spikes though CPU usage looks low (50%).Advanced`docker logs` is empty but the app is running.BeginnerConfigure log rotation globally.BeginnerShip container logs to a central system.Intermediate