Define a good restart policy for a production service.
BeginnerScenarioLimits, logging, health checks and restarts
Answer
Situation read → Containers should survive crashes and reboots.
What I'd do → --restart unless-stopped (or always); on-failure:5 for batch jobs. In Compose: restart: unless-stopped.
Why → unless-stopped honours an operator's explicit stop across daemon restarts, while always restarts regardless. Backoff doubles up to 1 minute for repeated failures.
Interview tip → Restart policy is not orchestration; it will not reschedule on another host.
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