Example — Template Content Type
Example title: Docker Compose Starter
Guidance: Use template for a complete, copy-paste starting file or scaffold. It should run with minimal edits and include placeholders where the reader must supply environment-specific values.
Example content
A Docker Compose starter template for a web app with a PostgreSQL database. Copy it into a project, replace the placeholder password, and run docker compose up -d.
Compose file
services:
web:
image: nginx:alpine
ports:
- "8080:80"
volumes:
- ./html:/usr/share/nginx/html:ro
restart: unless-stopped
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: changeme
volumes:
- db_data:/var/lib/postgresql/data
restart: unless-stopped
volumes:
db_data:
Usage
docker compose up -d
docker compose ps
Notes
- Replace
changemebefore using the template. - Keep the volume name stable so data survives restarts.
- Add a
.envfile when secrets should not live in the Compose file.