---
source: https://iinventedlight.com/library/notes/docker-restart-policies.md
title: "docker run --restart picks no, on-failure, always or unless-stopped"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs (Engine)); Apache-2.0 (Docker docs (CLI reference)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Docker docs (Engine), Start containers automatically; Docker docs (CLI reference), docker container run. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Docker restart policies"
tags: [docker, restart, restart-policy, unless-stopped, on-failure]
client: Librarian
sources:
  - id: S1
    title: "Start containers automatically"
    publisher: Docker docs (Engine)
    url: https://docs.docker.com/engine/containers/start-containers-automatically/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "docker container run"
    publisher: Docker docs (CLI reference)
    url: https://docs.docker.com/reference/cli/docker/container/run/
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# docker run --restart picks no, on-failure, always or unless-stopped
**Answer:** Restart policies control whether containers start automatically when they exit or when Docker restarts. Set one with `docker run --restart=VALUE`; the default is `no`. Docker recommends restart policies over process managers for starting containers.

## The four values

| Value | Description |
|---|---|
| `no` | Don't automatically restart the container (default). |
| `on-failure[:max-retries]` | Restart if it exits due to an error (non-zero exit code); optionally limit retries. A daemon restart does not restart the container. |
| `always` | Restart the container whenever it stops. If manually stopped, it's restarted only when the Docker daemon restarts or the container is manually restarted. |
| `unless-stopped` | Like `always`, except that a stopped container isn't restarted even after the Docker daemon restarts. |

```shell
docker run -d --restart unless-stopped redis
docker run -d --restart on-failure:5 myjob
```

## Details

- A restart policy only applies once a container has started successfully: up for at least 10 seconds, with Docker monitoring it. That keeps a container that never starts from a restart loop.
- Restart policies are different from the `--live-restore` flag of `dockerd`, which keeps containers running during a Docker upgrade.

## See also

- [docker-compose-basics](https://iinventedlight.com/library/notes/docker-compose-basics/)
- [docker-cli-readonly](https://iinventedlight.com/library/notes/docker-cli-readonly/)

## Claims

- id: C1
  claim: Restart policies control automatic restarts on exit or daemon restart.
  source: S1
  evidence: "restart policies to control whether your containers start automatically when they exit"

- id: C2
  claim: on-failure does not restart the container when the daemon restarts.
  source: S1
  evidence: "It doesn't restart the container if the daemon restarts."

- id: C3
  claim: unless-stopped does not restart a stopped container after daemon restarts.
  source: S1
  evidence: "it isn't restarted even after Docker daemon restarts"

- id: C4
  claim: The --restart flag sets a container's restart policy.
  source: S2
  evidence: "Use the --restart flag to specify a container's"

## Sources

- [S1] Start containers automatically. Docker docs (Engine). https://docs.docker.com/engine/containers/start-containers-automatically/ . License: Apache-2.0. Accessed 2026-11-18.

- [S2] docker container run. Docker docs (CLI reference). https://docs.docker.com/reference/cli/docker/container/run/ . License: Apache-2.0. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs (Engine), Start containers automatically; Docker docs (CLI reference), docker container run. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
