# Container Restart Policy

> A rule for whether a stopped box should start up again.

**Field:** Infrastructure  
**Category:** Containers  
**Also known as:** Restart Policy, docker run --restart, restart: unless-stopped

## Think of it like

Think of it like a toy that stands back up each time it falls over.

## Definition

A restart policy tells Docker what to do when a container stops. The default, no, leaves it stopped. on-failure starts it again only after an error. always starts it again whenever it stops. unless-stopped does the same, unless you stopped it yourself. The policy is how a container comes back after a crash or a reboot.

## Example

Emma runs her app with --restart unless-stopped. The server reboots at night for updates, and the app is back up before anyone notices.

## Example code

```bash
docker run -d --restart unless-stopped --name app myapp
```

This box comes back after a crash or a reboot. It stays off if Emma stops it.

## Why it matters

Without one, a crash or reboot leaves the app down until someone notices. It is the simplest way for a service to heal itself.

## Common mistake

Leaving the default on a server. The default is no, so nothing comes back after a reboot.

## Three principles

- **Default is no.** A stopped container stays stopped.
- **Four choices.** no, on-failure, always, unless-stopped.
- **Back after reboots.** always and unless-stopped return.

## Related terms

- [docker run](https://learn.benibix.com/term/infrastructure/docker-run)
- [Container](https://learn.benibix.com/term/infrastructure/container)
- [Docker](https://learn.benibix.com/term/infrastructure/docker)
- [Docker Compose](https://learn.benibix.com/term/infrastructure/docker-compose)
- [Health Check](https://learn.benibix.com/term/infrastructure/health-check)
- [Fault Tolerance](https://learn.benibix.com/term/infrastructure/fault-tolerance)

![An image on the left. An arrow labelled docker run leads to a running container. A side arrow labelled docker exec opens a shell inside it. Another arrow leads to a stopped container, and a curved arrow labelled restart policy leads back to running.](https://learn.benibix.com/diagrams/inf4-container-life.svg)

---

Source: https://learn.benibix.com/term/infrastructure/container-restart-policy
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
