Write a Docker Compose file
Describe your services — image, ports, environment, depends_on — and get a valid docker-compose.yml with correct indentation, instead of hand-writing fiddly YAML.
Open the tool, then paste the sample input below. Everything runs locally in your browser.
The problem
A Compose file is whitespace-sensitive YAML, so a wrong indent or a misplaced ports entry stops the stack from coming up. Building it from a few fields per service produces valid structure with the service wiring and port mappings in the right place.
Sample input
web: image nginx:1.27, port 8080->80, depends_on db
db: image postgres:16, env POSTGRES_PASSWORD=secret
Expected output
services:
web:
image: nginx:1.27
ports:
- "8080:80"
depends_on:
- db
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: secret
Ports are quoted "host:container", depends_on is a list, and environment is a map — the indentation that Compose requires is handled for you.
How to do it
- Add each service with its image.
- Set port mappings as host to container.
- Add environment variables and depends_on.
- Generate the docker-compose.yml.
- Copy it and run docker compose up.
Common mistakes
- Wrong indentation, which makes Compose reject the file.
- Writing a port as a number instead of a quoted "host:container" string.
- Using depends_on as a map instead of a list.
- Putting secrets directly in environment instead of an env file.
- Mixing the obsolete top-level version with the modern services key.
Related tools
Related guides
FAQ
How do I write a docker-compose.yml?
Define each service with an image, then add ports, environment, and depends_on. The helper emits valid Compose YAML with the indentation handled.
How do I map a port in Compose?
Use a quoted "host:container" string under ports, for example "8080:80". Writing a bare number maps a container port without a host port.
How do I express that one service needs another?
Use depends_on as a list of service names. It controls start order; for readiness you still need a healthcheck or retry in the app.
Where should secrets go?
Avoid hard-coding secrets in environment. Reference an env file or Docker secrets, and never commit real credentials.
Is my config uploaded?
No. The Compose file is generated locally in your browser. Nothing is sent to a server.
The Compose file is generated locally in your browser. Nothing is uploaded.
Build Compose and Kubernetes manifests, lint Dockerfiles, validate YAML — plus every other utility.
Practical example and expected result
Describe your services - image, ports, environment, depends_on - and get a valid docker-compose.yml with correct indentation, instead of hand-writing fiddly YAML. In practice, this is most useful when you need a quick, repeatable check on a Docker configuration before adding it to a ticket, pull request, test fixture, or support note.
A realistic input for this workflow is web: image nginx:1.27, port 8080->80, depends_on db db: image postgres:16, env POSTGRES_PASSWORD=secret. The expected result should resemble services: web: image: nginx:1.27 ports: - "8080:80" depends_on: - db db: image: postgres:16 environment: POSTGRES_PASSWORD: secret, with the same important values preserved.
Troubleshooting checklist
- Confirm you copied the complete Docker configuration and not only a partial line or truncated preview.
- Run the local tool once with a safe sample, then repeat with the real data only if your team policy allows it.
- Check quoting, escaping, whitespace, encoding, timestamps, and environment-specific values before trusting the result.
- Before sharing output, remove secrets, tokens, cookies, customer data, and production hostnames that are not needed for the review.
Next useful steps
- Open this example in Docker Compose Helper → for a related validation or follow-up step.
- Generate Kubernetes manifests for a related validation or follow-up step.
- Lint the Dockerfile for a related validation or follow-up step.
- Use Magic Box when you are not sure which tool should handle the next artifact.