CV-S004: Invalid Port Format
Error Schema
Why This Matters
Docker Compose supports two port mapping syntaxes. Short syntax uses strings like "HOST:CONTAINER", "CONTAINER", or "HOST:CONTAINER/PROTOCOL" (e.g., "8080:80/tcp"). Long syntax uses an object with target (required), published, protocol, and host_ip. A critical YAML pitfall: unquoted port mappings like 80:80 are interpreted as a base-60 integer (4880) by the YAML 1.1 parser, not as a string. Always quote port mappings in your Compose file to avoid silent misinterpretation.
How to Fix
Quote port mappings as strings and use valid HOST:CONTAINER or long syntax format.
Before (incorrect)
ports:
- 8080:80 After (correct)
ports:
- "8080:80" Rule Details
- Rule Code
- CV-S004
- Severity
- Error
- Category
- Schema