What You'll Learn
Beginner
- How to define a complete multi-service application
- How to use depends_on with health checks
A typical Docker Compose setup — frontend, backend, database, network, and volume
docker-compose.ymlyaml
services:
frontend:
build: ./frontend
ports: [3000:80]
depends_on: [api]
api:
build: ./api
ports: [8000:8000]
environment:
DB_HOST: db
depends_on:
db:
condition: service_healthy
db:
image: postgres:15
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 5s
retries: 5Key Takeaways
- Define a full stack in one file.
depends_onwithcondition: service_healthywaits for health checks.- Services resolve each other by name.
docker compose up --scale api=3runs multiple instances.
Comments
Comments
Post a Comment