1. Home
  2. Developer
  3. Docker Compose Generator

Docker Compose Generator

Add services and get a compose.yaml and .env.example.

For every format and option in one place, use Server Config Generators →

Runs in your browser · No upload
Add a service
Your app
Keep passwords as ${VARIABLE} references instead of values. Put the real values in a .env file.
PostgreSQL
Leave databases empty so only other services on the same network can reach them. If you must publish one, bind to localhost, e.g. 127.0.0.1:5432:5432.
Keep passwords as ${VARIABLE} references instead of values. Put the real values in a .env file.
compose.yaml
services: app: build: . restart: unless-stopped ports: - "3000:3000" environment: NODE_ENV: production networks: - app-net depends_on: postgres: condition: service_healthy postgres: image: postgres:17 restart: unless-stopped environment: POSTGRES_USER: app POSTGRES_DB: app POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env} volumes: - postgres-data:/var/lib/postgresql/data networks: - app-net healthcheck: test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER:-postgres}\""] interval: 10s timeout: 5s retries: 5 volumes: postgres-data: {} networks: app-net: driver: bridge
.env.example
# Copy to .env and fill in real values. Never commit .env to git. POSTGRES_PASSWORD=
How to run
# create .env and fill in the passwords cp .env.example .env # check the configuration docker compose config # start in the background docker compose up -d
Review the generated files before using them in production. Keep passwords in .env only and never commit .env to git.

Your input is processed in this browser and never sent to a server.

How to use

  1. Use the Add a service buttons to add your app, Nginx, PostgreSQL, MySQL, MariaDB, MongoDB, Redis or RabbitMQ as many times as you need. Adding the same kind again gets a numbered name so they do not clash.
  2. In each service card, edit the name, image tag, ports, environment, volumes and restart policy. For your own app, leave the image empty to build the current folder with build.
  3. Choose whether to use a dedicated network and healthchecks.
  4. Copy or download the generated compose.yaml and .env.example into one folder, run cp .env.example .env and fill in the passwords, then start with docker compose up -d.

Service presets

Service Default image Data volume Password variable
PostgreSQL postgres:17 postgres-data:/var/lib/postgresql/data POSTGRES_PASSWORD
MySQL mysql:8.4 mysql-data:/var/lib/mysql MYSQL_PASSWORD, MYSQL_ROOT_PASSWORD
MariaDB mariadb:11 mariadb-data:/var/lib/mysql MARIADB_PASSWORD, MARIADB_ROOT_PASSWORD
MongoDB mongo:8 mongo-data:/data/db MONGO_ROOT_PASSWORD
Redis redis:7-alpine redis-data:/data none (port not published)
RabbitMQ rabbitmq:4-management-alpine rabbitmq-data:/var/lib/rabbitmq RABBITMQ_PASSWORD
Nginx nginx:stable-alpine mounts ./nginx.conf read-only none

Change any image tag to the version you want. The tags are examples from when this page was written, so check that they exist on Docker Hub and are still supported.

What the output does

  • Passwords are never written into the file. DB passwords appear only as references like ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}; if .env lacks the value, docker compose stops before starting. .env.example lists the same variable names without values.
  • Databases do not publish host ports. App services on the same network reach them by service name (postgres, redis and so on). If you must publish one, bind to localhost with something like 127.0.0.1:5432:5432.
  • Start order: with healthchecks on, the app waits for service_healthy on each database. PostgreSQL is checked with pg_isready, MySQL with mysqladmin ping and Redis with redis-cli ping. With them off, you get a plain depends_on list.
  • Named volumes are registered in the top-level volumes: automatically; path binds such as ./data:/data are not.
  • If the PostgreSQL image is version 18 or newer, the data mount is changed to /var/lib/postgresql. Version 17 and older use /var/lib/postgresql/data.
  • Port mappings are always double-quoted so YAML does not read 80:80 as a base-60 number.

Things to know

  • To write a literal $ in an environment value, type $$. Compose substitutes anything that starts with $ as a variable.
  • A warning appears when a key containing PASSWORD, SECRET or TOKEN has a literal value. Even for local development, moving it to .env keeps the secret out of the repository.
  • Current compose files do not need a version: key, so none is generated.
  • Review the generated files before using them in production. Resource limits, logging and backups are not included. docker compose config shows the result after variable substitution.
  • Build your app image with the Dockerfile Generator and write the front proxy config with the Nginx Config Generator. The Env Converter converts .env formats and the JSON YAML Converter helps inspect the YAML structure. To run something on a host without Docker, see the systemd Service Generator.

Frequently asked questions

Should I name the file docker-compose.yml or compose.yaml?

Docker Compose V2 looks for compose.yaml first and still reads docker-compose.yml. This tool downloads compose.yaml, the currently recommended name.

What if my app starts before the database even with depends_on?

Plain depends_on only waits for the container to start, not for the database to be ready. Turn on the healthcheck option and the app waits for condition: service_healthy.

Where is volume data stored?

Named volumes live in an area managed by Docker and survive docker compose down. docker compose down -v deletes them too, and the data is gone, so be careful.

Can I write passwords directly in compose.yaml?

It works, but the file ends up in your repository and backups. This tool generates variable references plus .env, and warns if you type a value directly.

Is my input sent to a server?

No. The files are generated entirely in your browser.

Your input is processed in this browser and never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.