1. Services block
services is the top-level map; each key under it is one container in the app.
services:Typorithm · easy
Step 1 of 8 · intro card
Compose
A Compose file describes a multi-container app in one YAML file. Each service is built from a Dockerfile (build) or a prebuilt image, ports publishes them to the host, and depends_on sets start order — one docker compose up brings the whole stack up.
Docker Compose describes a multi-container application in a single YAML file under the services key. Each service becomes one container, configured independently.
A service gets its image either by building one (build pointing at a Dockerfile directory) or by pulling a prebuilt one (image). ports publishes a container port to the host as host:container.
depends_on declares that one service should start after another, so Compose orders startup. A single docker compose up brings the entire stack up, which is ideal for local development.
services lists every container in the app.
build builds an image; image pulls a prebuilt one.
depends_on sets the order services start in.
services:
web:
build: .
ports:
- "8080:80"
depends_on:
- db
db:
image: postgres:16Connect each part of the code to the concept before you type.
services is the top-level map; each key under it is one container in the app.
services:build points at a directory with a Dockerfile; Compose builds the image for this service.
build: .ports maps host:container, so localhost:8080 reaches port 80 inside the web container.
- "8080:80"depends_on makes Compose start the listed services first, controlling startup order.
depends_on:image pulls a prebuilt image from a registry instead of building one locally.
image: postgres:16Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.