Impact & Risk Analysis
- Severity: Low
- CIS Benchmark: CIS 5.15
- Impact: Denial of Service (DoS) & Masked Failures. If you indefinitely keep trying to start a broken container, it can consume excessive host resources (CPU/IO), potentially leading to a Denial of Service. Additionally, always restarting a container masks the underlying root cause of the crash, preventing proper investigation.
Common Misconfiguration
Usingrestart: always or restart: unless-stopped. While convenient for keeping services up, this configuration creates an infinite loop if the application crashes immediately upon startup, spamming the logs and burdening the Docker daemon.
Vulnerable Example
Secure Example
Audit Procedure
Run the command below to inspect the restart policy of all containers:- Result: Check the
RestartPolicyNameandMaximumRetryCount. - Fail: If
RestartPolicyNameisalwaysorunless-stopped. - Fail: If
RestartPolicyNameison-failurebutMaximumRetryCountis greater than 5 or 0 (unlimited). - Pass: If
RestartPolicyNameison-failureandMaximumRetryCountis 5 or less.
Remediation
You should use theon-failure restart policy and limit the number of container restarts to a maximum of 5 attempts. This ensures that if a container repeatedly fails, it stops eventually so you can investigate the error log.

