docker compose for app + DB
Exercise40 min
docker compose for app + DB
Compose declares a whole stack in one file — this app's own is running your database right now:
services:
postgres:
image: postgres:18.6-alpine
environment:
POSTGRES_PASSWORD: postgres
ports: ["5432:5432"]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]One command brings up the whole system; down -v erases it completely. Healthchecks make startup self-aware — the app waits until the database actually accepts connections instead of failing fast and asking you to retry.
Exercise
Read this repo's backend/docker-compose.yml. Add an app service that builds the backend Dockerfile and depends on postgres (with condition: service_healthy).
Practice in the diagram lab
This lesson's practice belongs in the diagram editor — design the schema you just read about, grade it against the solution, and save it to your account.
Open the diagram lab