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 →
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 ecosystem for building, distributing, and running applications in containers.
- Docker daemonconfigures · The Docker daemon is a background service that manages Docker images, containers, networks, storage, and container operations on behalf of clients.
- init containerconfigures · An init container is a Kubernetes Pod container that performs initialization work to completion before the Pod’s application containers start.
- podman runconfigured by · podman run is a Podman command that creates and starts a new container from an image.
- agent orchestrationcontrasts with · Orchestration is the coordination and sequencing of agents, services, tasks, or components to carry out a larger workflow or objective.
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.


