Pcornel
Containers · Docker & Compose Operations

Container Restart Policies

Cheat sheet · https://pcornel.dk/topic.php?topic=6139

Back to the Topic

Answer

Restart policies decide whether the runtime restarts a container when it exits: Docker no, on-failure, always, unless-stopped; Kubernetes pods use restartPolicy with backoff.

Remember

Restarts hide crashes — monitor restart counts and logs. Kubernetes restarts with exponential backoff (CrashLoopBackOff).

First checks

  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state

Commands

docker kill

Verify in this order

container exits → policy decides → restart with backoff

Where it usually breaks

Policy always also restarts containers you stopped once the daemon restarts.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6139

Confirmation

Confirm action

Continue?