restart policy
A setting that tells Docker or Kubernetes whether to start a container again automatically after it exits.
In more detail
Docker's choices are no (the default), on-failure[:max-retries], always and unless-stopped, set at run time on the container or Compose service rather than in the image. In Kubernetes, a pod's restartPolicy is Always (the default), OnFailure or Never. A restart loop with a nonzero exit code means read the logs, not raise the retries.
Examples
A restart policy only works if the supervised process stays in the foreground; a process that forks and exits looks like a clean exit.docker run -d --restart unless-stopped taskapi:0.1Related terms
- process supervisor — A program that starts processes, watches them and restarts them if they exit, such as systemd or a container platform.
- foreground process — A process that keeps running as the one its launcher started, instead of detaching into the background.
- container status — The current state of a container as Docker reports it, such as created, running, exited or restarting.
- exit code — A number a process returns when it finishes: 0 means success, anything else means something went wrong.
- health check — A regular automated test of whether a program or service is working, such as a request to its health endpoint or a command run inside its container.
Taught in
- Running, And Still Down — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Choose The Right Workload Resource — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Sidecars And Init Containers — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Probes And Health Checks — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Mock Exam: Sixteen Tasks Against The Clock — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Port Binding And Concurrency — DevOps & Site Reliability Engineering
- Run, Stop, Restart And Remove A Container — Docker Architecture & Production Containers
- Health Checks, Dependencies And Reliable Startup — Docker Architecture & Production Containers
- Diagnose Crashes, Resource Limits And Unhealthy Containers — Docker Architecture & Production Containers
- Harden And Deliver The Complete Service Stack — Docker Architecture & Production Containers
- From Local Containers To Kubernetes — Docker Architecture & Production Containers
- Pin It, Lint It, Prove It: Images And Runtimes — Kubernetes and Cloud Native Associate (KCNA) Exam Prep
- Five Jobs, Five Workloads — Kubernetes and Cloud Native Associate (KCNA) Exam Prep
- Slow, Or Broken? Metrics, Logs And Traces — Kubernetes and Cloud Native Associate (KCNA) Exam Prep
- Jobs And CronJobs — Kubernetes: Production-Grade Container Orchestration
- Global Error Trapping: uncaughtException & Exits — Node.js Internals & Backend Services