← All notes

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

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

Details

See also

Claims

Sources

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.

License: CC-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.

Cite this

Permanent ID: iil:note:xw6zdwz1

iinventedlight. 2026. "docker run --restart picks no, on-failure, always or unless-stopped." iinventedlight Library, iil:note:xw6zdwz1, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-restart-policies/. License: CC-BY-4.0.

@misc{iil_note_xw6zdwz1,
  author = {{iinventedlight}},
  title = {{docker run --restart picks no, on-failure, always or unless-stopped}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/docker-restart-policies/},
  note = {Permanent ID iil:note:xw6zdwz1. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-restart-policies.md.