Docker Compose Generator
Build a docker-compose.yml for one to three services — image, ports, environment, volumes and restart policy — as clean modern YAML.
A Compose file is a stack written down: which images run, which ports they publish, what environment they get, and what happens when they stop. Hand-writing the YAML is error-prone in specific, boring ways — indentation that looks right and is not, port mappings parsed as something other than strings, environment values that change type on the way in. This generator builds the file from a form so the structure is right by construction. Worked example: one service named web on image nginx:1.27, publishing 8080:80, with environment MODE=prod and restart policy unless-stopped, produces a services block in which web carries exactly image: nginx:1.27, a quoted "8080:80" port entry, MODE: prod under environment, and restart: unless-stopped — nothing more, because nothing more was asked for.
Everything you type stays in page memory on your device: it is never uploaded, stored or put into a link. Environment values often include passwords and tokens in real projects — generate with placeholder values here and fill the real ones in on the machine that runs the stack.
Quick answers
How do I create a docker-compose.yml?
Describe each service — name, image, ports as host:container, environment as KEY=value lines, volumes, restart policy — and copy the generated YAML. A web service on nginx:1.27 publishing 8080:80 with MODE=prod and restart unless-stopped is a complete, runnable starting point.
The file omits the obsolete version key on purpose and quotes port mappings, because unquoted YAML can misread them.
What does restart: unless-stopped do?
It restarts the container whenever it stops — after a crash or a host reboot — unless you stopped it deliberately with docker compose stop or down, in which case it stays stopped. It is the usual choice for services that should simply be up.
The alternatives in the form: always (restarts even after a manual stop, once the daemon restarts), on-failure (only after a non-zero exit), and no (never).
How to use
- Fill in service 1: a name, an image with its tag, and whichever of ports, environment and volumes it needs. Leave a field empty and it simply does not appear in the file.
- Add service 2 and service 3 the same way if the stack needs them — a database beside the app, a cache beside both. A service with neither a name nor an image is skipped.
- Write ports as host:container (8080:80 publishes container port 80 on host port 8080) and environment as one KEY=value per line.
- Copy the generated docker-compose.yml into your project folder and run docker compose up. The file deliberately has no version line — current Compose ignores it, and the page explains why below.
About this tool
Two choices in the output deserve explaining. First, there is no version: line at the top. The Compose specification dropped it: current Docker Compose treats the top-level version key as obsolete, warns about it, and reads the file the same without it, so generated files here omit it and stay warning-free. Second, port mappings and volume paths are always quoted. An unquoted 8080:80 can be read by a YAML parser as a number in base 60 rather than the string you meant, and quoting removes the whole class of surprise; environment values that look like numbers are quoted for the same reason, since Compose expects them as strings. The generator covers the everyday core — image, ports, environment, volumes, restart, depends_on and container naming in the underlying builder — and deliberately stops there: build contexts, secrets, healthchecks and networks are project-specific enough that a form would hide more than it helps. Your stack description never leaves the page; use placeholder values for anything secret and fill the real ones in on the host.
Frequently asked questions
Why is there no version line in the generated file?
Because the current Compose specification made the top-level version key obsolete: modern Docker Compose ignores it and prints a warning when it is present. Files generated here omit it, which is the documented, warning-free form for current tooling.
Why are the port mappings in quotes?
YAML can read an unquoted mapping like 8080:80 as a sexagesimal (base-60) number instead of a string, and some host:container pairs hit exactly that trap. Quoting every mapping makes the value unambiguously the string Compose expects.
How many services can I define?
The form builds one to three services, which covers the common small stacks — app plus database, app plus cache, or all three. The generated YAML is plain and additive: for a fourth service, copy an existing block in the file and rename it; the structure is identical.
Are environment values with numbers handled?
Yes — values that look purely numeric are quoted in the output, because Compose environment entries must be strings. MODE=prod stays plain, while a value like 8080 is emitted quoted so it arrives as the string "8080", not a number.
First time embedding? Read the step-by-step guide →
More free tools
UUID Generator
Generate random v4 UUIDs in bulk.
JSON Formatter & Validator
Format, minify and validate JSON in one click.
What Is My IP
See your public IP address instantly. No sign-up, nothing stored.
Regex Tester
Test, check and validate regular expressions with live highlighting.
JWT Decoder
Decode a JWT token without the secret — see its header and payload.
SHA-256 Hash Generator
Generate SHA-256 / SHA-512 hashes instantly.