Self-Healing Containers with Restart Policies

Learn how to use the container restart policies to ensure the smooth functioning of containers.

Container restart policies are a simple form of self-healing that allows the local Docker Engine to automatically restart failed containers.

Restart policies

We apply restart policies per container, and Docker supports the following four policies:

  • no (default)
  • on-failure
  • always
  • unless-stopped

The following table shows how each policy reacts to different scenarios. A Y indicates the policy will attempt a container restart, whereas an N indicates it won’t.

Get hands-on with 1400+ tech skills courses.