In short
Your app needs an API, Postgres and Redis. Starting three containers by hand with the right flags gets old fast. Compose starts the whole set with one command.
A tool for defining and running multi-container applications — e.g. your API plus its database plus Redis — together, with one YAML file and one command.

Think of it like this
The wedding caterer's master plan
A caterer doesn't shout instructions to each counter separately. One plan says: chaat here, sweets there, tandoor in the corner, start the tandoor first because it takes longest. Everyone sets up together. docker-compose.yml is that plan for your containers.
Watch it happen
docker compose up
docker compose up
1/6Compose reads docker-compose.yml in the current folder.
The big ideas
What you need to know
One file, whole stack
Services, ports, env vars, volumes and networks live in one YAML file you commit with the code.
Service names are hostnames
Inside the network, the api reaches Postgres at db:5432. No IP addresses needed.
Healthchecks beat waiting
depends_on alone only waits for the container to start. Add condition: service_healthy to wait until it's ready.
Daily commands
up -d to start, logs -f api to watch, down to stop. down -v also deletes volumes, so use it carefully.
See it in code
Walk through the code
1services:2 api:3 build: .4 ports: ["3000:3000"]5 environment:6 DATABASE_URL: postgres://app:secret@db:5432/app7 depends_on:8 db:9 condition: service_healthy10 db:11 image: postgres:1712 environment: { POSTGRES_USER: app, POSTGRES_PASSWORD: secret, POSTGRES_DB: app }13 healthcheck: { test: ["CMD", "pg_isready", "-U", "app"], interval: 5s }14 volumes: [pgdata:/var/lib/postgresql/data]15volumes: { pgdata: {} }1/4The api service is built from the Dockerfile in this folder and published on port 3000.
Modern Compose doesn't need a version: line at the top. For real secrets, use an env_file that's gitignored instead of writing passwords in the YAML.
Save yourself the pain
Common mistakes
Oops
Using localhost:5432 in the API's DATABASE_URL inside Compose.
Do this instead
Inside a container, localhost is the container itself. Use the service name, db.
Oops
Running docker compose down -v to 'restart cleanly'.
Do this instead
-v deletes your volumes and all your data. Plain down keeps them.
Your mission
API plus Postgres in one command
Quick check
Inside Compose, your API can't connect to postgres://localhost:5432. Why?
Go deeper
- 1Write a `docker-compose.yml` running your API alongside a PostgreSQL container.
- 2Learn how Compose handles networking between services automatically by service name.
- 3Practice `docker compose up`/`down` for the full local dev environment.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.