⚙️ Reading: YAML & JSON Configs
3 exercises — read real DevOps configuration files: a Docker Compose setup with healthchecks and a GitHub Actions CI pipeline. Understand what each block controls and why.
YAML reading quick reference
- Indentation = hierarchy (parent → child relationship)
key: value→ a single setting- item→ list item (starts with a dash)- HOST:CONTAINER port syntax — left side is your machine, right is inside the container
$${{ expression }}→ GitHub Actions variable interpolation
0 / 3 completed
1 / 3
docker-compose.yml
version: '3.9'
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:3000"
environment:
- NODE_ENV=production
- DATABASE_URL=postgres://user:pass@db:5432/myapp
depends_on:
db:
condition: service_healthy
restart: unless-stopped
volumes:
- ./uploads:/app/uploads
db:
image: postgres:15-alpine
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
POSTGRES_DB: myapp
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user -d myapp"]
interval: 10s
timeout: 5s
retries: 3
volumes:
pgdata: According to this docker-compose.yml, which port on the HOST machine maps to port 3000 inside the container?
Port 8080 on the host maps to port 3000 in the container:
The
Port mapping syntax:
Port
The
ports mapping uses "HOST:CONTAINER" syntax. So "8080:3000" means:- Host machine: localhost:8080 → forwards to → Container: port 3000 (where the Node.js app listens)
http://localhost:8080 on your machine, you reach the app that's running on port 3000 inside the container.Port mapping syntax:
"HOST_PORT:CONTAINER_PORT"- You can use any available host port on the left
- The right side is the port your app is configured to listen on inside the container
- Multiple services can use the same container port as long as they map to different host ports
Port
5432 is PostgreSQL's default port — it's used internally in the DATABASE_URL (@db:5432) but it's NOT mapped to the host (no ports: on the db service), so it's only reachable within the Docker network.