Docker Compose generator — app, database, Redis and nginx

Tick the services you need, and the tool writes a Docker Compose file plus a matching .env template, with current image tags, health checks and passwords that must be set before the stack starts.

Live demo · real result from this tool

compose.yaml (docker-compose.yml)

# docker-compose.yml (Compose Specification — the top-level “version:” key is obsolete and omitted)# Secrets come from a .env file next to this one; never commit it.services:  db:    image: postgres:18    restart: unless-stopped    environment:      POSTGRES_DB: app      POSTGRES_USER: ${POSTGRES_USER:-app}      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}    volumes:      # Postgres 18+ images keep data under /var/lib/postgresql (with a versioned subdirectory)      - db-data:/var/lib/postgresql    healthcheck:      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER:-app} -d app"]      interval: 10s      timeout: 5s      retries: 5  redis:    image: redis:8    restart: unless-stopped
    volumes:
      - redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
  web:
    build: .
    restart: unless-stopped
    ports:
      - "3000:3000"
    env_file: .env
    environment:
      PORT: "3000"
      DATABASE_URL: postgres://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD}@db:5432/app
      REDIS_URL: redis://redis:6379
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy

volumes:
  db-data:
  redis-data:

.env (fill in the passwords)

# .env — keep out of version controlPOSTGRES_USER=appPOSTGRES_PASSWORD= 

Image tags checked on 2026-10-02. Start with docker compose up -d. Passwords are required from .env, so the stack refuses to start without them.

Processed on your device — nothing is uploaded.

How to use the Docker Compose generator

  1. Keep Web app (built from ./Dockerfile) ticked and set the Web app port, or untick it to run only the backing services.
  2. Choose the Database: PostgreSQL, MySQL, MariaDB, MongoDB or None, and set the Database name.
  3. Tick Redis, nginx reverse proxy on port 80 and Adminer database UI (localhost only) as needed.
  4. Save the first file as compose.yaml and the second as .env in the same folder. Fill in every empty password in .env.
  5. Run docker compose up -d.

What it does and when to use it

Docker Compose starts several containers together from one file, the usual way to run an app with its database on a laptop or a small server. This tool follows current advice: no version key, health checks, and no passwords in the file. The Compose file reference documents every key.

Use it when you containerise a project or replace an old file. The web service builds from a Dockerfile in the same folder, which you can make with the Dockerfile generator. With the nginx option, write the server block with the nginx config generator and point it at http://web:3000. To list the app’s other variables safely, use the .env example generator.

How it works

  • Database: an official image (postgres:18, mysql:9.7, mariadb:12.3 or mongo:8.0), a named volume for data, and a health check such as pg_isready or mysqladmin ping.
  • Redis: redis:8 with a data volume and a redis-cli ping health check.
  • Web: build: ., env_file: .env, connection URLs, and depends_on with condition: service_healthy, so the app starts only after the database answers.
  • nginx: nginx:1.30-alpine on port 80 with ./nginx/default.conf mounted read-only. The web port is then exposed only inside the network.

Image tags were checked on 2026-10-02.

Worked examples

Default stack: app, PostgreSQL and Redis.

  db:
    image: postgres:18
    restart: unless-stopped
    environment:
      POSTGRES_DB: app
      POSTGRES_USER: ${POSTGRES_USER:-app}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}

The volume is mounted at /var/lib/postgresql, the layout PostgreSQL 18 images use. The .env holds POSTGRES_USER=app and an empty POSTGRES_PASSWORD=.

MySQL shop behind nginx. Database MySQL named shop, Redis off, nginx on. The app gets DATABASE_URL: mysql://${DB_USER:-app}:${DB_PASSWORD}@db:3306/shop, and .env asks for DB_PASSWORD and DB_ROOT_PASSWORD.

Nothing ticked. With no web app, no database and no Redis, the tool returns “Choose at least one service.”

Limits and tips

  • Never commit .env. Add it to .gitignore before the first commit.
  • Special characters in passwords such as @ or / break the connection URL; URL-encode them or avoid them.
  • The web container receives all of .env through env_file, including the database root password. Split the file if that matters.
  • For production, add backups for the database volume.

Frequently asked questions

Why does docker compose up stop with "set POSTGRES_PASSWORD in .env"?
The file uses the ${VAR:?message} form, which refuses to start when the variable is missing or empty. Set a strong password in the generated .env and run the command again.
Why is there no version line at the top?
The top-level version key is obsolete in the Compose Specification, and current Docker Compose warns about it. The tool leaves it out.
How does my app reach the database?
Services on the same Compose network find each other by service name. The app gets a ready DATABASE_URL (or MONGODB_URI) that points at the host db, and REDIS_URL points at redis:6379.
Is the database open to the internet?
No ports are published for the database or Redis, so only other containers in the stack can reach them. Adminer, if you tick it, is bound to 127.0.0.1:8080, so it is reachable only from the machine itself.
Should I call the file docker-compose.yml or compose.yaml?
Both names work. compose.yaml is the name the Compose Specification prefers; older guides use docker-compose.yml.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close