Xerobit

Docker-Compose Generator

Describe a service in the form and get a docker-compose.yml that follows the Compose Specification. Add ports, environment, volumes, networks, depends_on and a healthcheck, or start from a preset such as postgres or wordpress. It runs in your browser.

Preset services are added before your own service. Clear the image to get the preset alone.

Result

services:
  web:
    image: nginx:stable
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - "./html:/usr/share/nginx/html:ro"

How to use the docker compose generator

  1. Pick a preset for a ready-made service, or leave it on None and describe your own service.
  2. Enter the service name and image, then list ports, environment variables and volumes, one per line.
  3. Add depends_on, a restart policy, a command or a healthcheck if the service needs them.
  4. Copy the result into compose.yaml and start it with docker 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

FieldCompose keyExample
Imageimagenode:20-alpine
Portsports"8080:80"
EnvironmentenvironmentNODE_ENV: production
Volumesvolumes"pgdata:/var/lib/postgresql/data"
Depends ondepends_on- db
Restart policyrestartunless-stopped
Commandcommand"npm start"
Healthcheckhealthchecktest, interval, timeout, retries
Networksnetworks- 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:stable on port 80 serving a read-only ./html folder.
  • PostgreSQL: postgres:16 with a named data volume and a pg_isready healthcheck.
  • Redis: redis:7 with a data volume and a redis-cli ping healthcheck.
  • MySQL: mysql:8.0 with a data volume and a mysqladmin ping healthcheck.
  • MongoDB: mongo:7 with root credentials and a data volume.
  • WordPress: a wordpress service and a MySQL db service wired together with depends_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

ExampleInputResult
Nginx serving a folderStart from a preset: noneservices: / web: / image: nginx:stable / restart: unless-stopped / ports: / - "8080:80" / volumes: / - "./html:/usr/share/nginx/html:ro" /
PostgreSQL with a healthcheckStart from a preset: postgresservices: / 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 MySQLStart from a preset: wordpressservices: / 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 PostgresStart 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): shopname: 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