DevOpsTools & Guides

Docker Compose Validator – Fix YAML Before Deploy

Lint docker-compose.yml files, highlight missing restart policies, and download a cleaned manifest

No signup • Runs in browser • Free

Open the Docker Compose Validator →

Docker Compose powers the majority of local development stacks. It is terse, declarative, and right up until a release candidate – dangerously easy to break with an extra space or a missing colon. Unlike Kubernetes manifests, Compose files rarely receive schema validation beyond what the Docker CLI reports after a failure. The DevToolBox validator addresses this gap by performing the same whitespace and key structure checks that docker compose config performs while adding best-practice guidance for restart policies, resource limits, and env_file usage.

Why lint docker-compose.yml files?

  1. Indentation rules are strict. Compose files use two-space indentation. Tabs or inconsistent spacing cause CLI errors such as found character '\t' that cannot start any token. The validator highlights those lines immediately.
  2. Services need restart policies. Forgetting restart: unless-stopped or restart: on-failure leaves production containers vulnerable to silent exits. Warnings surface services that rely on the default policy.
  3. Resource limits matter. Compose stacks destined for ECS, Swarm, or Nomad benefit from explicit CPU and memory budgets. The validator detects services missing deploy.resources.limits.
  4. CI likes normalized files. Prettifying the YAML ensures git diffs stay predictable and merges remain clean.

Recommended validation workflow

  1. Paste or upload your compose file into the tool.
  2. Inspect the summary widget to confirm the number of services, volumes, and networks matches expectations.
  3. Review the Errors & Syntax Issues section for indentation problems, missing colons, or stray characters.
  4. Handle the Warnings list – typically missing restart policies or absent resource limits.
  5. Click Prettify YAML to normalize indentation and trailing whitespace, then download the cleaned file for git.

Pair this tool with the .env File Editor to guarantee that each service receives the same set of environment variables across machines.

Command-line validation cheatsheet

# Equivalent of the online validator in your terminal
docker compose config --quiet  # exits non-zero if YAML breaks

# Combine with schema validation for Compose v2
docker compose convert > /tmp/out.yml && yq eval '... comments=""' /tmp/out.yml >/dev/null

Additional checks:

  • Deprecated keys – Use the validator to find keys such as container_name or links which cause portability problems. Replace them with name: or networking primitives.
  • Env file drift – When you reference env_file, ensure those files exist locally. The validator lists them in the summary so you can commit the right sample envs.
  • Multi-file merges – Compose allows multiple YAML files via docker compose -f base.yml -f prod.yml up. The tool can still help; paste the merged result from docker compose config to check restart policies and limits.

Also read

Related Articles

Helpful tools for DevOps