CV-B002: No restart policy
Warning Best Practice
Why This Matters
Without a restart policy, a crashed container stays stopped until manually restarted. In production, services should automatically recover from crashes. The restart policy can be set via the top-level restart key or through deploy.restart_policy for Swarm-mode compatibility.
How to Fix
Add restart: unless-stopped or restart: on-failure for automatic crash recovery
Before (incorrect)
services:
web:
image: nginx After (correct)
services:
web:
image: nginx
restart: unless-stopped Rule Details
- Rule Code
- CV-B002
- Severity
- Warning
- Category
- Best Practice