Docker Compose YAML Validator

Paste your docker-compose.yml and get instant validation — service definitions, port mappings, depends_on cycles, named volumes, and more.

Share this tool
Load example:

Validating...

Paste your docker-compose.yml above and click Validate.

What Is Docker Compose?

Docker Compose is a tool for defining and running multi-container applications using a single YAML file — typically named docker-compose.yml or compose.yml. Instead of running a chain of long docker run commands, you declare every service, its image, environment variables, ports, volumes, and inter-service dependencies in one place.

A single docker compose up command starts your entire stack — web server, database, cache, worker — in the correct order based on depends_on relationships. This makes Compose the standard tool for local development and CI pipelines across the industry.

The Compose Spec (the modern standard, maintained at compose-spec.io) supersedes the older versioned formats (v2, v3). Files using the Compose Spec omit the top-level version: key entirely. All Docker Engine versions from 20.10 onwards support the Compose Spec natively.

What This Validator Checks

YAML Syntax

Detects malformed YAML — bad indentation, unclosed quotes, invalid scalars — before any semantic checks.

Service Definitions

Flags services that define neither image nor build, which will always fail at runtime.

depends_on Cycles

Runs a depth-first search to find circular dependencies that would hang docker compose up indefinitely.

Port Format

Validates port mapping syntax — host:container, ranges, and /tcp and /udp protocols.

Named Volumes

Warns when a named volume is referenced in a service but not declared in the top-level volumes: block.

Null Environment Variables

Info-level notice when an env var has a null value — Docker will source it from the host shell at startup.

Port Mapping Syntax Reference

Docker Compose supports several port mapping formats. All of the following are valid:

FormatMeaning
"80:80"Host port 80 → container port 80
"8080:80"Host port 8080 → container port 80
"80"Container port 80, random host port
"9000-9010:9000-9010"Port range mapping (must be same width)
"53:53/udp"UDP port mapping
"127.0.0.1:80:80"Bind to specific host IP (localhost only)

Always quote port mappings that start with a number in YAML — e.g. "80:80" not 80:80 — to avoid the colon being parsed as a YAML key separator.

Common Docker Compose Mistakes

Missing image and build

A service with no image: or build: cannot start. Docker has nothing to run. This is the most common first-time error.

Undeclared named volumes

Using my-data:/var/lib/data in a service requires a matching my-data: entry under the top-level volumes: block. Without it, Docker Compose will error on startup in strict mode or behave unexpectedly.

depends_on does not wait for readiness

depends_on only waits for the container to start — not for the service inside to be ready. Use healthcheck + condition: service_healthy for true readiness gating.

Keeping the version: key

The version: key is obsolete in the Compose Spec and is ignored by Docker Compose v2. Keeping it causes a deprecation warning. Remove it entirely in new files.

Frequently Asked Questions

Does this validator work with Docker Swarm configs?
Partially. Swarm-specific fields like deploy:, configs:, and secrets: are valid Compose Spec top-level keys and will not be flagged. However, this validator does not deeply validate Swarm-specific deploy constraints such as replica counts, placement rules, or update policies.
What is the difference between named volumes and bind mounts?
A named volume (e.g. db-data:/var/lib/postgresql/data) is managed by Docker and persists across container restarts. A bind mount (e.g. ./src:/app/src or /absolute/path:/container/path) maps a path on the host directly into the container. Named volumes must be declared in the top-level volumes: block; bind mounts do not.
Why does my valid-looking YAML fail validation here?
The most common cause is tab characters — YAML requires spaces for indentation, never tabs. Another frequent cause is unquoted port mappings like 80:80 (without quotes), which YAML parsers interpret as a key-value pair, not a string. Use "80:80" (with double quotes) instead.
What does "sources from shell" mean for null environment variables?
When you write MY_VAR: (with no value) in your environment block, the YAML value is null. Docker Compose interprets this as "pass the value of MY_VAR from the current shell environment into the container." If the variable is not set in the shell, the container receives an empty string or the variable is absent entirely. This is intentional for secrets injection but easy to get wrong — hence the info notice.

Related Developer Tools