How do I validate a Docker Compose file online?
Paste your docker-compose.yml and click Validate to check for syntax errors, invalid service configurations, undefined networks, circular dependencies, and best practice violations. The tool formats your compose file and highlights issues with fix suggestions. Everything runs in your browser.
version: "3.8"
services:
web:
image: nginx:alpine
ports:
- "80:80"
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: secret✓ Valid Docker Compose file Services: 2 (web, db) Networks: 1 (default) Volumes: 0 Version: 3.8
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
imageorbuilddirective - Network and volume references resolve to declared resources
depends_onreferences 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.
Tips & Best Practices
Always pin image versions — never use :latest in production
image: postgres:latest means your dev, staging, and production environments can run different Postgres versions. Pin to a specific version (postgres:16.2-alpine) for reproducible builds. Use Docker Compose's extends feature or .env files to manage version numbers centrally.
depends_on only waits for container start, not readiness
depends_on: [db] starts the database container before your app, but doesn't wait for it to accept connections. Your app will crash connecting to a database that's still initializing. Use healthcheck + condition: service_healthy, or add retry logic in your app's database connection code.
Use named volumes for database persistence across restarts
Without a named volume, docker compose down destroys your database data. Define volumes: db-data: and mount it with volumes: - db-data:/var/lib/postgresql/data. Named volumes persist across container lifecycle changes. Use docker compose down -v only when you intentionally want to reset data.
Never hardcode secrets in docker-compose.yml
Environment variables with passwords (POSTGRES_PASSWORD: mysecret) get committed to version control. Use env_file: .env with .env in .gitignore, or Docker Secrets for Swarm mode. For local development, docker compose supports a .env file that's automatically loaded.
Frequently Asked Questions
How do I validate a Docker Compose file?
What is the difference between Docker Compose v2 and v3 file formats?
How do I define health checks and service dependencies in Docker Compose?
Related Inspect Tools
Dockerfile Validator
Validate and lint Dockerfiles for syntax errors, security issues, best practices, and layer optimization
Kubernetes YAML Validator
Validate Kubernetes manifests for syntax, required fields, best practices, security, and resource limits
OpenAPI / Swagger Validator
Validate OpenAPI 3.x and Swagger 2.0 specs for structure, paths, schemas, security, and best practices
.env File Validator
Validate .env files for syntax errors, duplicate keys, security risks, and best practices — export .env.example templates