CV-M002: Circular depends_on chain
Error Semantic
Why This Matters
A circular dependency exists between services via their depends_on declarations. Docker Compose cannot determine a valid startup order when services form a cycle (e.g., A depends on B, B depends on C, C depends on A). Compose will reject the file at startup with a "circular dependency" error. Break the cycle by removing one of the depends_on links or restructuring service relationships.
How to Fix
Remove one depends_on link to break the circular chain.
Before (incorrect)
services:
web:
depends_on: [api]
api:
depends_on: [db]
db:
depends_on: [web] After (correct)
services:
web:
depends_on: [api]
api:
depends_on: [db]
db:
image: postgres Rule Details
- Rule Code
- CV-M002
- Severity
- Error
- Category
- Semantic