Docker Compose Generator
Writing a docker-compose.yml by hand means remembering the exact indentation, quoting every port mapping, and knowing which version string your Compose binary understands. This generator lets you define services through simple fields: a name, an image, host:container port mappings and volumes. It outputs a valid YAML file with the modern Compose spec (no version key) and sensible defaults.
How to build a Compose file
-
1
Add services
Set a name, an image, host:container port mappings and volumes for each service. Two starter services are already filled in.
-
2
Adjust or remove rows
Edit any field directly, add another service with the + Service button, or remove a row you do not need.
-
3
Check the generated YAML
The preview updates as you type: port mappings are quoted and the version key is omitted, as the modern Compose spec expects.
-
4
Copy the file
Copy the generated docker-compose.yml and paste it into your project root.
The modern Compose spec
Compose V2 (the plugin shipped with Docker Desktop and modern Docker Engine) follows the Compose Specification. The version: key is deprecated; the generator omits it. Top-level keys are services, networks, volumes, configs and secrets.
Service anatomy
A production-leaning service looks like this:
services:
web:
image: nginx:1.27-alpine
restart: unless-stopped
ports:
- "80:80"
volumes:
- ./public:/usr/share/nginx/html:ro
depends_on:
app:
condition: service_healthy
networks:
- frontend
- backend
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost/health"]
interval: 30s
timeout: 5s
retries: 3
Volumes: bind mount vs named
- Bind mount (
./app:/var/www) ties the container to a path on the host; great for local development because changes reflect immediately. - Named volume (
pgdata:/var/lib/postgresql/data) is managed by Docker and persists independent of any host path; the right choice for databases and anything you do not want to delete accidentally withrm -rf. - Anonymous volume - avoid. It survives restarts but disappears on
docker compose down -vwithout warning.
Networks
By default Compose creates a network named after the project and connects every service to it. Declaring explicit networks is useful when:
- You want to isolate a database from a public-facing service.
- You need a bridge with a custom subnet to align with existing infrastructure.
- You want to attach containers to a pre-existing external network (
external: true).
Common mistakes to avoid
- Version key conflicts.
version: "3.8"at the top prevents newer features like healthcheckstart_intervalfrom working in old Compose; the generator omits the version key. - Port quoting.
8080:80parses as YAML base-60 in some edge cases; the generator always quotes port mappings. - Hard-coded secrets. Secrets written directly into compose.yml end up committed to git. Keep them in an
env_fileor in the platform’s secret store instead. - depends_on without condition. Plain
depends_on: [db]waits for the container to start, not the service to be ready. Usecondition: service_healthyand add a healthcheck to the dependency.
Frequently Asked Questions
The current Compose Specification (aligned with Docker Compose V2). The file omits the version: key, which is how modern Compose files are written. It works with Docker Compose V2.22 and newer.
Not through the form in this version. The generator focuses on service definitions with image, ports and volumes. You can add networks, environment variables, health checks and other keys to the generated YAML by hand before using it.
No, this tool focuses on compose.yml. For Dockerfiles, use the Dockerfile Generator, which handles the base image choice and the COPY/RUN ordering for five stacks.
No. The service definitions are used only to build the YAML on this page. They are not stored, uploaded or shared.
Related Tools
ASCII Table Reference
Full ASCII table from 0 to 127 with decimal, hex, octal, binary, standard names and HTML numeric-reference notation, including NUL, LF and DEL.
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
HEX Color Picker
Pick or enter a HEX colour and get RGB, HSL, approximate CMYK, relative luminance and contrast ratios against white and black.
HTML Character Reference
Searchable list of HTML entities, their named and numeric codes, and a one-click copy for special characters and symbols.
JSON Formatter
Paste JSON to pretty-print with 2 or 4 spaces, minify it to compact output, or run a quick syntax check before copying the result.
Phone Validator
Validate phone numbers by country, detect the region and type, and normalize valid numbers to E.164, international, national and RFC 3966 formats.
Tool available in other languages
- Generator Docker Compose [PL]
- Gerador de Docker Compose [PT]
- مولّد Docker Compose [AR]
- Generador de Docker Compose [ES]
- Générateur Docker Compose [FR]
- Docker Compose 생성기 [KO]
- Docker Compose Oluşturucu [TR]
- Docker Compose-generator [SV]
- Trình tạo Docker Compose [VI]
- Generator Docker Compose [ID]
- Docker Composeジェネレーター [JA]
- ตัวสร้าง Docker Compose [TH]
- Docker Compose-generator [NL]
- Docker-Compose-Generator [DE]
- Docker Compose 生成器 [ZH]
- Generatore di Docker Compose [IT]
- Генератор Docker Compose [RU]