Build a Compose file from Postgres, MySQL, Redis, Mongo, RabbitMQ and more, with health checks wired into dependencies so services start in a usable order.
2 services · checked against this site's own compose inspector
0 notes, all of which depend on what the stack is for.
Passwords are written as ${VAR:?message} references, never as literals. The :? form makes compose refuse to start when the variable is unset, rather than quietly using an empty password — which is the failure mode of the plain ${VAR} form.
# A starting point. Review it before running:
# ports, credentials and volume paths all depend on your machine.
#
# There is no `version:` key — the compose specification dropped it,
# and Compose V2 warns when it is present.
services:
app:
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
ports:
# Quoted, because YAML reads a bare h:mm as a number.
- "3000:3000"
environment:
NODE_ENV: production
DATABASE_URL: postgres://app:${POSTGRES_PASSWORD}@postgres:5432/app
env_file:
# Values live here, outside version control.
- .env
depends_on:
postgres:
condition: service_healthy
postgres:
image: postgres:17-alpine
restart: unless-stopped
environment:
POSTGRES_USER: app
POSTGRES_DB: app
# Read from .env rather than written here.
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
ports:
# 127.0.0.1 only: without it this is reachable from the network.
- "127.0.0.1:5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app -d app"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s
volumes:
postgres-data:
Checked against this site's compose inspector: no warnings. Every port is quoted, every datastore is bound to localhost, and no password is a literal.
This is a starting point and its first line says so. It assumes a conventional layout — a Dockerfile in the project root, an .env alongside it holding the passwords the ${VAR} references read. The image versions are pinned to what was current when this was written; check them against what you want before running it.
Docker Compose Generator runs entirely on your device — nothing is uploaded.
You’re on the Free plan. Compare plans
`depends_on` on its own only waits for a container to start, which for a database means the process exists and is not yet accepting connections. Your application starts, fails to connect, and restarts. Every service generated here has a health check, and dependencies use `condition: service_healthy` so the ordering is real.
State goes in named volumes, not bind mounts. A bind-mounted database directory runs into file permission and locking differences between Linux, macOS and Windows, and the failures are obscure. A named volume is managed by Docker and behaves the same everywhere.
Every image is pinned to a version. The generator's own inspector flags `latest`, and a generator that emitted output its inspector warned about would not be worth much — so the two agree, and that agreement is asserted by a test.
Credentials in the generated file are development defaults and are visible in it, which is correct for a local stack and wrong for anything else. The page says so where the credentials are, and the environment variables are written to read from a `.env` so the file itself can be committed.
No Docker command is run and the local daemon is never contacted. This generates text to review before use.
Because by default it waits for the container to start, not for the service inside it to be ready. Postgres accepts connections a second or two after the process starts. `depends_on` with `condition: service_healthy` plus a health check is what actually waits.
A named volume. A bind mount puts the database's files on your host filesystem, where permission models and locking differ between operating systems, and the resulting corruption is hard to diagnose. Bind mounts are for source code you are editing.
They are development defaults, visible in the file, and fine for a local stack on your own machine. They are not safe for anything reachable from a network. The environment block reads from a .env so real values never go in the committed file.
No. The Compose Specification dropped it and current versions of Compose ignore it, sometimes with a warning. Files written for Compose v1 still have it; new files should not.
No. No Docker command is run and the daemon is never contacted. You get a file to review and run yourself.