Docker Compose Validator
Paste a docker-compose.yml or compose.yaml file
and get an instant report of syntax errors and structural problems: missing
images, bad port mappings, undeclared volumes and networks, broken
depends_on references, and YAML type traps like
restart: false.
Related tools
What is checked
- YAML syntax with the failing line highlighted.
- Top-level structure: a
servicesmapping must exist; unknown top-level keys are flagged unless they start withx-. - Every service must be a mapping with either
imageorbuild. - Ports must be valid
HOST:CONTAINERmappings, optionally with an IP, a range, or/udp. - depends_on targets must be defined services, and conditions must be one of the three allowed values.
- Named volumes and networks used by a service must be declared at the top level.
- environment must be a list of
KEY=valuestrings or a mapping of scalars; boolean values are flagged so you can quote them. - restart must be
no,always,on-failure, orunless-stopped. - container_name duplicates and healthcheck blocks without a
testare reported. - Unknown service keys (usually typos like
enviroment) are reported as warnings.
Example
services:
web:
build: .
ports:
- "8000:8000"
depends_on:
- db
volumes:
- app-data:/data # not declared below
db:
image: postgres:16
restart: no # quote it: YAML 1.1 parsers read this as false
volumes:
db-data:
The validator reports the undeclared app-data volume. Click Load sample above
for a longer example with more issues.
Common Docker Compose YAML mistakes
- Indentation under a service. If the keys under
web:are not indented,webis parsed as null and the validator reports that it must be a mapping. - Unquoted port ranges. Values like
8080:80are safe in YAML 1.2 parsers but quoting them avoids surprises with tools that still use YAML 1.1. - Mixing list and map syntax.
environmentaccepts either- KEY=valueitems orKEY: valuepairs, not both in one block. - Boolean strings.
DEBUG: falsepasses the boolean to your app; if it expects the text "false", quote it.
Once the file is clean, keep it that way with the YAML formatter, and compare environments with the YAML diff tool.
Frequently asked questions
Do I still need the version key?
No. The Compose Specification used by Docker Compose v2 ignores the top-level version field and prints a warning when it is present. You can delete it. The validator flags it as informational rather than an error.
Should I quote restart: no?
Yes. YAML 1.1 parsers (and older Compose releases) read the bare word no as the boolean false and then reject the value. This validator uses YAML 1.2, where no stays a string, so it only flags the value when it was parsed as a boolean. Writing restart: "no" is safe everywhere.
Is this a full replacement for docker compose config?
No. docker compose config validates against the complete Compose schema and resolves variables and includes. This tool catches YAML errors and the most common structural mistakes instantly in the browser, without Docker installed.
Should the file be named docker-compose.yml or compose.yaml?
Docker Compose v2 looks for compose.yaml first, then compose.yml, docker-compose.yaml, and docker-compose.yml. All work; compose.yaml is the preferred modern name. See .yml vs .yaml.