How to use the docker compose generator
- Pick a preset for a ready-made service, or leave it on None and describe your own service.
- Enter the service name and image, then list ports, environment variables and volumes, one per line.
- Add depends_on, a restart policy, a command or a healthcheck if the service needs them.
- Copy the result into
compose.yamland start it withdocker compose up -d.
What this docker-compose generator writes
A Compose file describes the containers of an application in one YAML document. This docker-compose generator builds that document from form fields, so you do not have to remember key names or YAML quoting. The result uses the current Compose Specification: a top-level services map, optional networks and volumes maps, and an optional name for the project. It does not write the old version key, which Compose V2 ignores and warns about.
Every form field becomes one key under the service. Image tags are exactly what you type, and the presets use real official tags such as postgres:16, redis:7, mysql:8.0 and mongo:7. An image with no tag is flagged, because it pulls the latest version.
Form fields and the Compose keys they create
| Field | Compose key | Example |
|---|---|---|
| Image | image | node:20-alpine |
| Ports | ports | "8080:80" |
| Environment | environment | NODE_ENV: production |
| Volumes | volumes | "pgdata:/var/lib/postgresql/data" |
| Depends on | depends_on | - db |
| Restart policy | restart | unless-stopped |
| Command | command | "npm start" |
| Healthcheck | healthcheck | test, interval, timeout, retries |
| Networks | networks | - backend |
Ports, volumes and networks
Ports are always written as quoted strings. Unquoted values such as 22:22 can be read by YAML 1.1 parsers as a base-60 number, so the quotes are a safeguard. Accepted forms are a single container port, host:container, ip:host:container, ranges and a /tcp or /udp suffix.
A volume whose source is a plain name, like pgdata, is a named volume. The generator adds it to the top-level volumes map for you. A source that starts with ./ or / is a bind mount and needs no declaration. Named volumes survive docker compose down and are removed only by docker compose down -v. Network names you enter are added to the top-level networks map, which lets services talk to each other by service name.
depends_on, healthchecks and start order
The depends_on list tells Compose to start dependencies first. That only orders container starts. It does not wait for a database to accept connections. For that, add a healthcheck to the dependency and use the long form condition: service_healthy in your own file, or retry the connection inside the application.
A healthcheck runs a command inside the container on a schedule. The generator writes test as ["CMD-SHELL", "your command"] so shell operators like || work, or as the exact array when you start the field with a bracket. Intervals use Compose durations such as 30s or 1m30s. Inside a healthcheck or environment value, write $$ to pass a literal dollar sign, because Compose treats a single $ as variable interpolation.
Presets for common stacks
- Nginx:
nginx:stableon port 80 serving a read-only./htmlfolder. - PostgreSQL:
postgres:16with a named data volume and apg_isreadyhealthcheck. - Redis:
redis:7with a data volume and aredis-cli pinghealthcheck. - MySQL:
mysql:8.0with a data volume and amysqladmin pinghealthcheck. - MongoDB:
mongo:7with root credentials and a data volume. - WordPress: a
wordpressservice and a MySQLdbservice wired together withdepends_on.
Passwords in presets are the placeholder change-me, and the tool warns you to replace them. Keep real secrets in an .env file or Docker secrets rather than in the file you commit. To check the file, run docker compose config. Related converters: YAML validator and YAML formatter.
Worked examples
| Example | Input | Result |
|---|---|---|
| Nginx serving a folder | Start from a preset: none | services: / web: / image: nginx:stable / restart: unless-stopped / ports: / - "8080:80" / volumes: / - "./html:/usr/share/nginx/html:ro" / |
| PostgreSQL with a healthcheck | Start from a preset: postgres | services: / db: / image: postgres:16 / restart: unless-stopped / ports: / - "5432:5432" / environment: / POSTGRES_USER: app / POSTGRES_PASSWORD: change-me / POSTGRES_DB: app / volumes: / - pgdata:/var/lib/postgresql/data / healthcheck: / test: ["CMD-SHELL","pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] / interval: 10s / timeout: 5s / retries: 5 / volumes: / pgdata: {} / |
| WordPress with MySQL | Start from a preset: wordpress | services: / wordpress: / image: wordpress:latest / restart: unless-stopped / ports: / - "8080:80" / environment: / WORDPRESS_DB_HOST: db / WORDPRESS_DB_USER: wordpress / WORDPRESS_DB_PASSWORD: change-me / WORDPRESS_DB_NAME: wordpress / volumes: / - wordpress:/var/www/html / depends_on: / - db / db: / image: mysql:8.0 / restart: unless-stopped / environment: / MYSQL_DATABASE: wordpress / MYSQL_USER: wordpress / MYSQL_PASSWORD: change-me / MYSQL_RANDOM_ROOT_PASSWORD: "1" / volumes: / - db:/var/lib/mysql / volumes: / wordpress: {} / db: {} / |
| Node app that depends on Postgres | Start from a preset: postgres; Service name: api; Image: node:20-alpine; Ports (one per line): 3000:3000; Environment (KEY=value per line): NODE_ENV=production / DB_HOST=db; Depends on (service names): db; Restart policy: unless-stopped; Command (optional): npm start; Networks (names): backend; Project name (optional): shop | name: shop / services: / db: / image: postgres:16 / restart: unless-stopped / ports: / - "5432:5432" / environment: / POSTGRES_USER: app / POSTGRES_PASSWORD: change-me / POSTGRES_DB: app / volumes: / - pgdata:/var/lib/postgresql/data / healthcheck: / test: ["CMD-SHELL","pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] / interval: 10s / timeout: 5s / retries: 5 / api: / image: node:20-alpine / restart: unless-stopped / command: "npm start" / ports: / - "3000:3000" / environment: / NODE_ENV: production / DB_HOST: db / networks: / - backend / depends_on: / - db / networks: / backend: {} / volumes: / pgdata: {} / |
FAQ
What is a docker-compose generator?
It is a form that writes the docker-compose.yml for you. You enter images, ports, volumes and other settings, and the tool outputs valid YAML you can run with docker compose up.
Does this docker compose generator add a version line?
No. The version key is obsolete in the Compose Specification, and Compose V2 prints a warning when it is present.
Why are my ports in quotes?
Quoting keeps YAML from reading a pair like 22:22 as a number. Compose accepts the quoted string and starts the same port mapping.
Does depends_on wait for the database to be ready?
Not by itself. It starts containers in order. Add a healthcheck to the database and use condition: service_healthy, or let your app retry its connection.
Can I add more than one service?
Pick a preset to add its services, then fill in your own service in the form. Together they are written into one file. For a larger stack, run the tool again and merge the results.
Is my configuration uploaded?
No. The file is generated in your browser and nothing is sent to a server.
Sources and references
- Compose file reference, Docker Docs: service, volume and network keys