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.1

Related terms

Taught in

References

Certification courses