Restart policy
A restart policy is a configuration rule specifying whether and when a container or workload is automatically restarted after termination or failure.
Kubernetes in Action, Second Edition
The OnFailure restart policy directs Kubernetes to restart containers when they terminate unsuccessfully.
- How it is used
- Controls whether exited pod containers are replaced and whether a failed Job task is retried inside its pod.
- How deep it goes
- Defines all three policies and traces container recreation, retry delays, init-container failures, and Job-level failure handling.
- Examples
- Uses a Job manifest with `restartPolicy: OnFailure` and contrasts same-pod retries with replacement pods under `Never`.
- What you can do after
- Operate/configure it by choosing a Job pod’s restart policy and identifying whether failed work retries in its pod or a replacement pod.
Read how Kubernetes in Action, Second Edition explains restart policy →
Kubernetes for Developers
A restart policy is a Pod setting that determines whether workloads are restarted after termination or failure.
- How it is used
- Configures how Kubernetes handles container exits inside Pods, especially terminating workloads managed by Jobs.
- How deep it goes
- Explains OnFailure, Never, and Always through Job behavior, but defers broader Pod lifecycle details.
- Examples
- Uses one-off task Jobs and parallel Redis queue workers configured with Never or OnFailure.
- What you can do after
- Operate/configure Jobs with a restart policy matched to failure recovery, debugging, or successful termination.
Read how Kubernetes for Developers explains restart policy →
Build and Orchestrator in Go (From Scratch)
container.RestartPolicy is a Docker API configuration structure specifying how a container is handled after termination or failure.
- How it is used
- Specifies how the Docker daemon handles a container after termination, providing a resilience mechanism in task configuration.
- How deep it goes
- Defines four policy values and their exit or stop behavior, then examines failure ownership in orchestrated systems.
- Examples
- Uses a Config struct and docker run --restart=on-failure:1 for an echo-server container.
- What you can do after
- Operate/configure Docker containers with no, on-failure, always, or unless-stopped restart behavior.
Read how Build and Orchestrator in Go (From Scratch) explains restart policy →
Also covered in
- Learn Docker in a Month of Lunches, Second Edition
- Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more
What to know first
- containerA software container is an isolated execution environment that packages an application and its dependencies, typically sharing the host operating-system kernel.
Related concepts
- jobconfigures · A Kubernetes Job is a workload resource that runs Pods for a finite task and tracks execution until the required successful completions are reached.
- Dockerused by · Docker is a platform and toolset for building, distributing, and running applications in containers.
- Docker daemonconfigures · The Docker daemon is a background service that builds and manages Docker images, containers, networks, storage, and related operations for clients.
- init containerconfigures · An init container is a Kubernetes Pod container that performs initialization work to completion before the Pod’s application containers start.
- container auto-restartconfigures · Container auto-restart is the automatic restarting or replacement of a terminated container by its runtime or orchestrator without manual intervention.
- agent orchestrationcontrasts with · Agent orchestration is the coordination of agents, their tasks, tools, and interactions to accomplish a larger objective or workflow.
Questions about restart policy
What is restart policy?
A restart policy is a configuration rule specifying whether and when a container or workload is automatically restarted after termination or failure.
Which Manning books explain restart policy?
Kubernetes in Action, Second Edition, Kubernetes for Developers and Build and Orchestrator in Go (From Scratch).
What should I know before learning restart policy?
Manning books that teach restart policy usually introduce container first.
What is the difference between restart policy and agent orchestration?
A restart policy is a configuration rule specifying whether and when a container or workload is automatically restarted after termination or failure. Agent orchestration is the coordination of agents, their tasks, tools, and interactions to accomplish a larger objective or workflow.
What is restart policy also called?
Restart policy is also called restartPolicy.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


