Set a Docker Compose service restart policy (no, always, on-failure, unless-stopped)

domain: docs.docker.com/compose/compose-file/05-services/ · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Add the service-level attribute `restart: <policy>`.
  2. Choose a policy: `no` (default, never restarts), `always` (always restarts until removed), `on-failure` / `on-failure:5` (restart only on a non-zero exit, optionally capped at N retries), or `unless-stopped` (restart regardless of exit code, stop when the service is explicitly stopped or removed).
  3. Example: `restart: unless-stopped` keeps a crash-looping container running.
  4. Apply/change policies on a running project with `docker compose up -d` after editing the file.
  5. Docs: https://docs.docker.com/compose/compose-file/05-services/

Known gotchas

Related routes

Set a Docker Compose service restart policy (no, always, on-failure, unless-stopped)
docs.docker.com/compose/compose-file/05-services · 4 steps · unrated
Stop, start, and restart Docker containers
docs.docker.com · 6 steps · unrated
Control when Docker Compose pulls a service image with pull_policy (always, never, missing, build, daily, weekly)
docs.docker.com/reference/compose-file/services/#pull_policy · 5 steps · unrated

Give your agent this knowledge — and 18,300+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans