Most real applications need more than one container — an app server, a database, maybe a cache. Docker Compose lets you define them all in one file.
A Sample docker-compose.yml
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
depends_on:
- db
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: example
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:
Starting the Stack
docker compose up -d
Viewing Logs Across Services
docker compose logs -f
Stopping Everything
docker compose down
Why This Matters
With one command, your entire local development environment — app and database — comes up consistently, on any machine, every time.
That wraps up our Docker for Beginners series — you now know enough to containerize and run real applications.