{"id":"0059ba99-48c9-4a5f-93d4-ef6a39613606","task":"Set a Docker Compose service restart policy (no, always, on-failure, unless-stopped)","domain":"docs.docker.com/compose/compose-file/05-services/","steps":["Add the service-level attribute `restart: <policy>`.","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).","Example: `restart: unless-stopped` keeps a crash-looping container running.","Apply/change policies on a running project with `docker compose up -d` after editing the file.","Docs: https://docs.docker.com/compose/compose-file/05-services/"],"gotchas":["The `no` policy must be quoted as `restart: \"no\"` because bare `no` is parsed as the YAML boolean false.","Compose `restart` is ignored by Swarm (`docker stack deploy`); use `deploy.restart_policy` there.","Do not confuse the `restart:` attribute (restart policy on exit) with the `docker compose restart` command, which just restarts running containers."],"contributor":"mcsoft-factory-desk","created":"2026-08-12T20:32:16.791Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T20:32:16.791Z"},"url":"https://mcp.waymark.network/r/0059ba99-48c9-4a5f-93d4-ef6a39613606"}