Skip to main content

Docker Compose Generator

Build a docker-compose.yml from per-service inputs in your browser.

Written by Golam Rabbani, Founder & Lead Engineer

Add one block per service. Ports, environment variables, and volumes accept one entry per line. The output is a valid Compose v3-style file using the modern (top-level services:) shape.

Service #1

e.g. "8080:80"

data:/var/lib/db or ./html:/usr/share/nginx/html

How to use this docker compose generator

  1. Fill in the first service block with a name and image (e.g. web, nginx:1.27-alpine).
  2. Add port mappings, environment variables, and volumes — one entry per line in each box.
  3. Click + Add service to add more services and link them with depends_on as needed.
  4. Pick a restart policy and an optional command override.
  5. Click Generate to produce a valid docker-compose.yml, then Copy YAML to paste into your project.

About this docker compose generator

The Docker Compose generator builds a valid `docker-compose.yml` from a service-by-service form. Each block becomes an entry under the top-level `services:` key using the modern Compose v3-style shape (no obsolete `version:` field, which Compose v2+ ignores anyway).

Inputs are validated: service names must start with a letter or underscore and use only letters, digits, and underscores; ports, env vars, and volumes are split per line and YAML-quoted only when needed (so a plain string like `8080:80` stays unquoted but `PATH=/usr/bin:/bin` is double-quoted). Named volumes referenced in any service (e.g. `data:/var/lib/db`) are automatically added under a top-level `volumes:` block at the end.

As a worked example, two services — `web` (nginx:1.27-alpine, port 8080:80) and `db` (postgres:16, env POSTGRES_PASSWORD=secret, volume pgdata:/var/lib/postgresql/data) with `web` depending on `db` — generate:

services: web: image: nginx:1.27-alpine ports: - "8080:80" depends_on: - db db: image: postgres:16 environment: POSTGRES_PASSWORD: secret volumes: - pgdata:/var/lib/postgresql/data

volumes: pgdata: {}

Generation is fully client-side; no data leaves your browser.

FAQ

Why does the output not include a `version:` line at the top?
Docker Compose v2 (the current `docker compose` plugin) ignores the `version:` field and Compose v3 deprecates it. Adding it back is harmless but unnecessary; leaving it off keeps the file shorter and matches modern Docker docs.
How are environment variables and ports formatted?
Ports are emitted as quoted strings (e.g. `"8080:80"`) so YAML never reads `80:80` as a sexagesimal number — a classic Compose gotcha. Environment lines are written as a mapping (`KEY: value`) when you use `KEY=value`, with values quoted only when they contain shell-significant characters.
Does the generator handle named volumes automatically?
Yes. Any volume whose left-hand side is a name (e.g. `data:/var/lib/db`) is collected into a top-level `volumes:` block at the bottom of the file. Bind mounts (e.g. `./html:/usr/share/nginx/html`) are emitted unchanged and do not need declaration.
Where do I save the generated docker-compose.yml file?
Put it at the root of your project. From that directory you can run `docker compose up -d` to start every service or `docker compose down` to stop them. Compose looks for `docker-compose.yml` or `compose.yaml` by default.
Does this tool send my service configuration anywhere?
No. Everything happens in your browser — there is no upload, no logging, and no server-side step. Close the tab and the form contents are gone.
Is this Docker Compose generator free to use?
Yes, it is completely free with no account, no signup, and no usage limits.