Skip to main content

CV-S002: Unknown Top-Level Property

Error Schema

Why This Matters

Docker Compose files only allow a fixed set of top-level keys: services, networks, volumes, secrets, configs, name, and version (deprecated). Any other key is rejected by the compose-spec schema. Common typos include "service" instead of "services" and "volume" instead of "volumes". If you need custom metadata, use extension fields prefixed with "x-" (e.g., x-common-env), which the spec explicitly allows and Docker Compose ignores during deployment.

How to Fix

Use a valid top-level property name or prefix custom properties with x-.

Before (incorrect)

service:
  web:
    image: nginx

After (correct)

services:
  web:
    image: nginx

Rule Details

Rule Code
CV-S002
Severity
Error
Category
Schema

Related Rules