docker-compose.yml Generator
Compose a Docker service declaration from simple options: service name, image, container name, published ports, environment variables, volumes and a restart policy. The tool emits a clean, valid docker-compose.yml you can paste into your project, with proper YAML quoting of port mappings and environment lines.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
A single-service compose file
Pick a service name and describe one container: its image, an optional container name, comma-separated published host:container ports, per-line environment KEY=value pairs, per-line bind-mount volumes in host:container form, and one of four restart policies. The output is a version-pinned docker-compose.yml with a services block holding a single service beneath it.
When a hand-written service block saves time
Reach for it when spinning up a quick local dependency — a database, a queue, a sidecar — and you want the YAML right the first time. Paste the result into your compose file or docker-compose up -f it directly; the generated restart line, port list and volume mounts are already in valid v3 form.
Ports, environment and volumes input rules
Ports are comma-separated host:container pairs, environment and volumes are one entry per line, and each is emitted as a quoted YAML string so colons and spaces never break the parse. An empty container name, empty ports, or empty volumes simply omits that key from the output.
Validation and YAML quoting
The service name must be lowercase alphanumeric with dashes, and an image is required or the tool stops with an error. Values are wrapped in double quotes with backslashes and quotes escaped, so a password with a colon or a mount path with a space survives round-tripping.
Nothing is sent off this device
The file is assembled entirely in this tab and returned as text you copy; your image names, ports and secrets never leave the browser.
Questions
Which fields can I set?
Service name, image, container name, published ports (host:container), environment variables, bind-mount volumes and a restart policy. Unused optional fields are omitted so the YAML stays clean.
Is the YAML valid?
Very likely — ports and environment lines are emitted as YAML strings, which avoids the classic colon-parsing traps. If you edit it by hand, keep that quoting.
Can I add more services?
This builds a single-service file. Reproduce it per service and merge the services: block, or push each generated file through a YAML formatter afterwards.
Related tools
See categoryJSON to YAML
Convert JSON to YAML on your device, with a 2- or 4-space indent.
JSON to .env
Flatten a JSON config into .env lines: VAR__NESTED=value, arrays as JSON, quoting handled.
.env <-> JSON
Parse a .env file into JSON, or turn a JSON object into .env text. Runs entirely on your device.
INI Converter
Convert INI config files to JSON or serialize JSON back to INI, on device.