CV-S007: Invalid Restart Policy
Error Schema
Why This Matters
Docker Compose supports exactly four restart policies: "no" (the default, container does not restart automatically), "always" (always restarts on exit regardless of exit code), "on-failure" (restarts only on non-zero exit code), and "unless-stopped" (restarts on exit unless the container was explicitly stopped). Common mistakes include using "never" instead of "no", "on_failure" with an underscore instead of "on-failure" with a hyphen, or boolean true/false. Always quote "no" in YAML because the bare word no is parsed as boolean false in YAML 1.1.
How to Fix
Use a valid restart policy: "no", "always", "on-failure", or "unless-stopped".
Before (incorrect)
restart: never After (correct)
restart: "no" Rule Details
- Rule Code
- CV-S007
- Severity
- Error
- Category
- Schema