DevBolt

Docker Compose Syntax Reference

Learn every key in the Docker Compose specification with clear explanations. Test your configurations live in the browser — no Docker installation needed.

← Back to tools

Docker Compose Validator

Validate and format Docker Compose files. Checks YAML syntax, service structure, network and volume references, dependency chains, and common misconfigurations.

About Docker Compose Validation

Docker Compose is a tool for defining and running multi-container applications. Compose files use YAML to configure your app's services, networks, and volumes.

What we check:

  • Valid YAML syntax with precise error locations
  • Top-level structure (services, networks, volumes, configs, secrets)
  • Service keys against the Compose specification
  • Every service has an image or build directive
  • Network and volume references resolve to declared resources
  • depends_on references exist and don't self-reference
  • Port format validity and restart policy values
  • Unused declared volumes and networks

Format: Re-serializes your Compose file with consistent indentation and optionally sorted keys, making it easier to review and compare in version control.

Everything runs in your browser — no data is sent over the network.

Docker Compose file structure

A Docker Compose file defines services (containers), networks, volumes, and optionally configs and secrets. Each service specifies an image or build context, port mappings, environment variables, volume mounts, and dependencies. The file uses YAML syntax, so proper indentation with spaces (not tabs) is critical.

Common use cases

Developers reference the Compose specification when adding health checks to services, configuring resource limits for staging environments, setting up inter-service networking, managing persistent storage with named volumes, and implementing graceful shutdown with stop_signal and stop_grace_period. The reference is invaluable when migrating from Compose V1 to V2 syntax.

Frequently Asked Questions

What is the difference between Compose V1 and V2?

Compose V2 is a Docker CLI plugin (docker compose) replacing the standalone Python-based V1 (docker-compose). V2 uses the Compose Specification, supports GPU resources, profiles, and service dependencies with conditions. The version key is deprecated in V2.

How do I set environment variables in Docker Compose?

Use the environment key for inline variables, env_file to load from a .env file, or combine both. Variables in .env files at the project root are automatically interpolated in the YAML using ${VARIABLE} syntax.