Interview Prep/Docker/Limits, logging, health checks and restarts

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.

All Docker questions Roadmap: Docker & containers

More on Limits, logging, health checks and restarts