Skip to content
Hands-on IT IT Drills

Appendix B: Final Exam

Goal: Apply the book without instructions: in eight exercises, turn the bare demo application into a healthy, hardened, CI-ready stack, plus a short knowledge section. · Duration: approx. 150 min · Prerequisite: Day 15

Rules of Play

  • Every exercise lists requirements and a check made of individual commands. You pass it when every command shows what is expected. Only read the solution afterwards.
  • The exercises build on each other and all run in ~/compose-lab/anhb. You start with the demo application from Day 0 – without a compose.yaml.
  • Allowed are Appendix A, docker compose … --help and the official docs, not Days 1–15. The finished solution is in code/anhb/loesung/.
  • You pass with eight passed checks and at least 8 out of 10 points in the knowledge section.
source ~/compose-lab/setup/env.sh
docker compose -p notes down
mkdir -p ~/compose-lab/anhb && cd ~/compose-lab/anhb
cp -R "$LAB/code/notes/." .

IDs, sizes and times in the outputs will differ on your machine.

Exercise 1: Three services, two networks

Part A (Days 1, 2, 4). Write compose.yaml:

  • Project notes, services api, worker, web, built from the three folders; worker and web reach api at http://api:8080.
  • Ports only on 127.0.0.1, changeable via API_PORT/WEB_PORT (default 8080/3000).
  • Networks frontend and backend, backend internal; worker only in backend, web only in frontend.
  • The API key comes from .env; if it’s missing, Compose aborts with a message.

Check:

docker compose up -d --build --wait
docker compose ps --format '{{.Service}} {{.Ports}}'

Expected (shortened): three services, ports only on 127.0.0.1.

 Container notes-api-1 Healthy
 Container notes-web-1 Healthy
api 127.0.0.1:8080->8080/tcp
web 127.0.0.1:3000->3000/tcp
worker

POST via web:

curl -s -X POST localhost:3000/api/notes -H 'Content-Type: application/json' \
  -d '{"text":"Anhang B"}'; echo

Expected (shortened, ID differs):

{"id":"e03888b4-73c1-418c-a7ee-5fe873fac1c7","text":"Anhang B"}

backend is internal:

docker network ls --filter name=notes_ --format '{{.Name}} internal={{.Internal}}'

Expected:

notes_backend internal=true
notes_frontend internal=false

worker can’t reach the internet, web doesn’t see worker:

docker compose exec worker python -c \
  "import urllib.request as u; u.urlopen('https://example.com', timeout=3)" 2>&1 \
  | tail -1
docker compose exec web nslookup worker 2>&1 | grep -m1 NXDOMAIN

Expected (shortened):

urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
** server can't find worker.localdomain: NXDOMAIN

Without .env, Compose aborts:

docker compose --env-file /dev/null up --dry-run 2>&1 | tail -1

Expected (shortened):

error while interpolating services.worker.environment.NOTES_API_KEY: required variable
NOTES_API_KEY is missing a value: NOTES_API_KEY fehlt (.env)

Solution

cat > compose.yaml <<'EOF'
# compose.yaml – Appendix B, Exercise 1
name: notes

services:
  api:
    build: notes-api
    environment:
      NOTES_API_KEY: ${NOTES_API_KEY:?NOTES_API_KEY fehlt (.env)}
    ports:
      - "127.0.0.1:${API_PORT:-8080}:8080"
    networks: [frontend, backend]

  worker:
    build: notes-worker
    environment:
      NOTES_API_URL: http://api:8080
      NOTES_API_KEY: ${NOTES_API_KEY:?NOTES_API_KEY fehlt (.env)}
    networks: [backend]
    depends_on: [api]

  web:
    build: notes-web
    environment:
      NOTES_API_URL: http://api:8080
      NOTES_API_KEY: ${NOTES_API_KEY:?NOTES_API_KEY fehlt (.env)}
    ports:
      - "127.0.0.1:${WEB_PORT:-3000}:3000"
    networks: [frontend]
    depends_on: [api]

networks:
  frontend: {}
  backend:
    internal: true
EOF
docker compose --env-file /dev/null up --dry-run 2>&1 | tail -1

Expected:

error while interpolating services.worker.environment.NOTES_API_KEY: required variable
NOTES_API_KEY is missing a value: NOTES_API_KEY fehlt (.env)

api is attached to both networks and is the only bridge. --env-file /dev/null replaces .env with an empty file – that’s how you check required variables without touching the real file.

Save your progress? Sign up for free

Exercise 2: Postgres and startup order

Parts A and B (Days 3, 5). Extend the file:

  • Service db with postgres:18.6-alpine, user and database notes, password from .env (required), volume pgdata at the correct path, only in backend, no port.
  • api stores data in Postgres. A job migrate creates the table (notes-api migrate).
  • After down -v, up -d --wait reliably starts with exit code 0; worker and web wait for a healthy api; web has its own healthcheck.

Check: empty volume, then start up:

docker compose down -v
docker compose up -d --wait
docker compose ps -a migrate --format '{{.State}} {{.ExitCode}}'

Expected (shortened):

 Container notes-db-1 Healthy
 Container notes-migrate-1 Exited
 Container notes-api-1 Healthy
 Container notes-web-1 Healthy
exited 0

A note survives down and up:

curl -s -X POST localhost:8080/notes -H 'X-API-Key: lab-api-key-123' \
  -H 'Content-Type: application/json' -d '{"text":"Anhang B persistent"}'; echo
docker compose down
docker compose up -d --wait
curl -s localhost:8080/notes | jq -r '.[].text'

Expected (shortened):

{"id":"51dee9cd-d766-4242-9297-b39a8c954a3a","text":"Anhang B persistent"}
…
 Container notes-db-1 Healthy
 Container notes-migrate-1 Exited
 Container notes-api-1 Healthy
 Container notes-web-1 Healthy
Anhang B persistent

db’s volume and ports:

docker compose config --format json | jq '.services.db.volumes'
docker compose ps db --format '{{.Ports}}'

Expected:

[
  {
    "type": "volume",
    "source": "pgdata",
    "target": "/var/lib/postgresql",
    "volume": {}
  }
]
5432/tcp

Solution

The services from Exercise 1 get depends_on in the long form and restart: unless-stopped; migrate and db are new (complete in code/anhb/loesung/compose.yaml, already including the following exercises):

  api:
    build: notes-api
    environment:
      NOTES_API_KEY: ${NOTES_API_KEY:?NOTES_API_KEY fehlt (.env)}
      NOTES_DB_URL: "postgres://notes:\
        ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD fehlt (.env)}@db:5432/notes"
    # … ports, networks as in Exercise 1 …
    depends_on:
      db:
        condition: service_healthy
      migrate:
        condition: service_completed_successfully
    restart: unless-stopped

  migrate:
    build: notes-api
    command: ["migrate"]
    environment:
      NOTES_DB_URL: "postgres://notes:\
        ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD fehlt (.env)}@db:5432/notes"
    networks: [backend]
    depends_on:
      db:
        condition: service_healthy
    restart: "no"
    healthcheck:
      disable: true

  # worker and web: depends_on api with condition: service_healthy,
  # restart: unless-stopped; web additionally:
  #   healthcheck:
  #     test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/healthz"]
  #     interval: 10s
  #     timeout: 2s
  #     start_period: 10s
  #     start_interval: 1s

  db:
    image: postgres:18.6-alpine
    environment:
      POSTGRES_USER: notes
      POSTGRES_DB: notes
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD fehlt (.env)}
    volumes:
      - pgdata:/var/lib/postgresql
    networks: [backend]
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "pg_isready", "-h", "127.0.0.1", "-U", "notes", "-d", "notes"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 30s
      start_interval: 1s

volumes:
  pgdata: {}

Every line has its day: -h 127.0.0.1 against the temporary init server (5), restart: "no" for the job (5, Day 15 Round 9), /var/lib/postgresql for Postgres 18 (3).

Save your progress? Sign up for free

Exercise 3: Configuration without data loss

Part A (Day 4). Extend the file:

  • An init script db/init/10-readonly.sql creates the role notes_ro (NOLOGIN, member of pg_read_all_data) and goes into the container via configs:.
  • The role also exists in your existing volume – the note from Exercise 2 stays.
  • worker polls every WORKER_INTERVAL seconds (default 10), every 5 in your setup.

Check:

docker compose exec db ls /docker-entrypoint-initdb.d
docker compose exec db psql -U notes -d notes -tAc \
  "SELECT rolname FROM pg_roles WHERE rolname = 'notes_ro'"

Expected:

10-readonly.sql
notes_ro

The note from Exercise 2 is still there, worker polls every 5 s:

curl -s localhost:8080/notes | jq -r '.[].text'
docker compose logs worker | grep 'worker started' | tail -1

Expected (shortened):

Anhang B persistent
worker-1  | worker started, api=http://api:8080, interval=5s

Solution

mkdir -p db/init
cat > db/init/10-readonly.sql <<'EOF'
-- Läuft nur beim ersten Start mit leerem Volume (docker-entrypoint-initdb.d)
CREATE ROLE notes_ro NOLOGIN;
GRANT pg_read_all_data TO notes_ro;
EOF
printf '\nWORKER_INTERVAL=5\n' >> .env

In compose.yaml:

  worker:
    environment:
      # … as before …
      INTERVAL: ${WORKER_INTERVAL:-10}

  db:
    # … as before …
    configs:
      - source: db_init
        target: /docker-entrypoint-initdb.d/10-readonly.sql

configs:
  db_init:
    file: ./db/init/10-readonly.sql

The init script only runs with an empty volume. Instead of down -v (note gone), you apply it once by hand:

docker compose up -d --wait
docker compose exec -T db psql -U notes -d notes < db/init/10-readonly.sql

Expected (shortened):

 Container notes-db-1 Recreated
 Container notes-worker-1 Recreated
 …
CREATE ROLE
GRANT ROLE

Save your progress? Sign up for free

Exercise 4: Backup and restore

Parts A and B (Days 3, 7). Put tools in a separate file compose.tools.yaml that compose.yaml pulls in via include:

  • psql (client from the Postgres image) and backup (writes backup/notes.sql), both in the profile tools, both in backend.
  • After down -v you restore the note from the backup.

Check:

docker compose up -d --wait
docker compose run --rm psql -c 'SELECT 1'
docker compose ps -aq psql | wc -l

Expected (shortened): psql answers, and no psql container is left over.

 ?column? 
----------
        1
(1 row)

0

Backup with the note:

docker compose run --rm backup
grep -c 'Anhang B persistent' backup/notes.sql

Expected (shortened):

1

After down -v everything is empty; after the restore it’s back:

docker compose down -v
docker compose up -d --wait
curl -s localhost:8080/notes; echo
docker compose run --rm -T psql -q < backup/notes.sql >/dev/null
curl -s localhost:8080/notes | jq -r '.[].text'

Expected (shortened):

…
[]
Anhang B persistent

The role notes_ro is back too:

docker compose exec db psql -U notes -d notes -tAc \
  "SELECT rolname FROM pg_roles WHERE rolname = 'notes_ro'"

Expected:

notes_ro

Solution

cat > compose.tools.yaml <<'EOF'
# compose.tools.yaml – tools, pulled in via include
services:
  psql:
    image: postgres:18.6-alpine
    profiles: [tools]
    entrypoint: ["psql"]
    environment:
      PGHOST: db
      PGUSER: notes
      PGDATABASE: notes
      PGPASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD fehlt (.env)}
    networks: [backend]
    depends_on:
      db:
        condition: service_healthy
  backup:
    extends: psql
    entrypoint: ["sh", "-c", "pg_dump --clean --if-exists > /backup/notes.sql"]
    volumes:
      - ./backup:/backup
networks:
  backend:
    internal: true
EOF

At the top of compose.yaml, directly after name: notes:

include:
  - compose.tools.yaml

run starts services with a profile even without --profile. After down -v, the init script creates the role again, migrate creates the empty table, and the backup with --clean --if-exists replaces it including its content.

Save your progress? Sign up for free

Exercise 5: Developing with watch

Part B (Days 6, 7):

  • compose.dev.yaml starts web from the build stage with node --watch and NODE_ENV=development – only with -f.
  • With docker compose -f compose.yaml -f compose.dev.yaml watch, a change to notes-web/public/index.html is visible after a few seconds without a rebuild.
  • Without -f, web runs in the prod image as user node again afterwards.

Check: in a second terminal, start docker compose -f compose.yaml -f compose.dev.yaml watch and wait for Watch enabled. Then here:

sed -i '' 's#<h1>notes</h1>#<h1>notes dev</h1>#' notes-web/public/index.html
sleep 5
curl -s localhost:3000/ | grep '<h1>'
docker compose exec web printenv NODE_ENV

Expected: the change is visible without a rebuild, dev mode is active.

  <h1>notes dev</h1>
development

You stop watch with Ctrl+C. Then back to the prod variant:

sed -i '' 's#<h1>notes dev</h1>#<h1>notes</h1>#' notes-web/public/index.html
docker compose up -d --build --wait
docker compose exec web id -u
docker compose exec web printenv NODE_ENV

Expected (shortened):

 Image notes-web Built
 Container notes-web-1 Recreated
 …
 Container notes-web-1 Healthy
1000
production

Solution

cat > compose.dev.yaml <<'EOF'
# compose.dev.yaml – development, only via -f together with compose.yaml
services:
  web:
    build:
      target: build
    command: ["node", "--watch", "server.js"]
    environment:
      NODE_ENV: development
EOF

In compose.yaml for web (without watch it has no effect):

    develop:
      watch:
        - action: sync
          path: ./notes-web/public
          target: /app/public
        - action: sync+restart
          path: ./notes-web/server.js
          target: /app/server.js
        - action: rebuild
          path: ./notes-web/package.json

The file is deliberately not called compose.override.yaml (Day 15, Round 6). Without an explicit image:, the dev build tags notes-web with the build stage – hence --build when switching back.

Save your progress? Sign up for free

Exercise 6: Building with versions

Part B (Day 8):

  • api and migrate use one image ${COMPOSE_PROJECT_NAME}-api:${TAG:-dev} from the final stage, with VERSION = TAG; worker and web are named analogously.
  • /version returns the tag.
  • Service api-test in the profile test builds the test stage (build = test run).

Check:

TAG=2.0 docker compose build
docker image ls notes-api:2.0

Expected (shortened, ID and size differ):

 Image notes-worker:2.0 Built
 Image notes-api:2.0 Built
 Image notes-web:2.0 Built
IMAGE           ID             DISK USAGE   CONTENT SIZE   EXTRA
notes-api:2.0   fa5046f5bf77       16.4MB          4.5MB
TAG=2.0 docker compose up -d --wait
curl -s localhost:8080/version; echo
docker compose ps -a migrate --format '{{.Image}}'

Expected (shortened):

 Container notes-api-1 Recreated
 …
 Container notes-api-1 Healthy
 …
2.0
notes-api:2.0

The tests run as a build:

docker compose --profile test build api-test; echo "Exit: $?"

Expected (shortened):

#13 [test 1/1] RUN --mount=type=cache,target=/go/pkg/mod … go test ./...
 …
 Image notes-api:test Built
Exit: 0

Solution

x-api-build: &api-build
  context: notes-api
  target: final
  args:
    VERSION: ${TAG:-dev}

services:
  api:
    build: *api-build
    image: ${COMPOSE_PROJECT_NAME}-api:${TAG:-dev}
    # …
  migrate:
    build: *api-build
    image: ${COMPOSE_PROJECT_NAME}-api:${TAG:-dev}
    # …
  worker:
    build: notes-worker
    image: ${COMPOSE_PROJECT_NAME}-worker:${TAG:-dev}
    # …
  web:
    build: notes-web
    image: ${COMPOSE_PROJECT_NAME}-web:${TAG:-dev}
    # …
  api-test:
    profiles: [test]
    build:
      context: notes-api
      target: test
    image: ${COMPOSE_PROJECT_NAME}-api:test

Compose provides COMPOSE_PROJECT_NAME for interpolation, even when it comes from name:. The anchor keeps both build definitions identical.

Save your progress? Sign up for free

Exercise 7: Hardening and secrets

Part C (Days 9, 10). For api (and migrate, where it makes sense):

  • Read-only file system, no capabilities, no-new-privileges.
  • At most 0.50 CPU, 64 MB of memory, 100 processes.
  • The API key and DB URL come as secret files from secrets/, not from the environment.

Check:

docker compose up -d --wait
docker compose config --format json \
  | jq '.services.api | {read_only, cap_drop, security_opt}'
docker compose config --format json | jq '.services.api.deploy.resources.limits'

Expected (shortened):

{
  "read_only": true,
  "cap_drop": [
    "ALL"
  ],
  "security_opt": [
    "no-new-privileges:true"
  ]
}
{
  "cpus": 0.5,
  "memory": "67108864",
  "pids": 100
}

Key from the file, not from the environment:

docker compose logs api | grep -o 'source=[a-z]*'
docker compose config --format json | jq '.services.api.environment'

Expected:

source=file
{
  "NOTES_API_KEY_FILE": "/run/secrets/api_key",
  "NOTES_DB_URL_FILE": "/run/secrets/db_url"
}

POST with the key:

curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:8080/notes \
  -H 'X-API-Key: lab-api-key-123' -H 'Content-Type: application/json' \
  -d '{"text":"gehärtet"}'

Expected:

201

Solution

mkdir -p secrets
printf '%s\n' lab-api-key-123 > secrets/api_key.txt
printf '%s\n' 'postgres://notes:lab-db-pw-123@db:5432/notes' > secrets/db_url.txt
chmod 644 secrets/*.txt
x-hardening: &hardening
  read_only: true
  cap_drop: [ALL]
  security_opt: ["no-new-privileges:true"]

services:
  api:
    # … build, image …
    <<: *hardening
    environment:
      NOTES_API_KEY_FILE: /run/secrets/api_key
      NOTES_DB_URL_FILE: /run/secrets/db_url
    secrets: [api_key, db_url]
    deploy:
      resources:
        limits:
          cpus: "0.50"
          memory: 64M
          pids: 100
    # … ports, networks, depends_on, restart …
  migrate:
    # … build, image, command …
    <<: *hardening
    environment:
      NOTES_DB_URL_FILE: /run/secrets/db_url
    secrets: [db_url]

secrets:
  api_key:
    file: ./secrets/api_key.txt
  db_url:
    file: ./secrets/db_url.txt

Warning: pids_limit: 100 next to deploy.resources.limits aborts in Compose 5.6.0: can't set distinct values on 'pids_limit' and 'deploy.resources.limits.pids'. The limit then belongs in limits.pids.

notes-api is a static binary in scratch and needs no writable file system. secrets/ is in .gitignore; the files are bind mounts, the permissions from the Mac apply, hence 644 in the lab (Day 10).

Save your progress? Sign up for free

Exercise 8: Compose in CI

Part D (Day 13):

  • compose.ci.yaml (only with -f) removes all published ports and brings along a service tests that runs a smoke test within the network: healthz of api and web, POST without key → 401, POST via web → 201.
  • ci.sh starts with its own project name, returns the tests’ exit code and always cleans up – containers, volumes and its own images – even on errors.
  • Your stack on port 8080 keeps running meanwhile.

Check:

bash ci.sh; echo "Exit: $?"
NOTES_API_KEY=lab-api-key-456 bash ci.sh; echo "Exit: $?"

Expected (shortened): green, then red.

 Container ci-…-tests-run-… Created
✔ api healthz
✔ web healthz
✔ POST ohne Key
✔ POST über web
Exit: 0
…
✔ api healthz
✔ web healthz
✔ POST ohne Key
✘ POST über web (401)
Exit: 1

No CI leftovers, your stack keeps running:

docker ps -a --filter label=com.docker.compose.project --format '{{.Names}}' \
  | grep -c '^ci-'
docker image ls --format '{{.Repository}}' | grep -c '^ci-'
curl -s localhost:8080/healthz; echo

Expected:

0
0
ok

Solution

mkdir -p tests
cat > tests/smoke.sh <<'EOF'
#!/bin/sh
# smoke.sh – smoke test in the CI network, output ✔/✘, exit code = number of failures
fail=0
check() {
  if [ "$2" = "$3" ]; then echo "✔ $1"; else echo "✘ $1 ($2)"; fail=$((fail + 1)); fi
}
code() { curl -s -o /dev/null -w '%{http_code}' "$@"; }
check "api healthz" "$(curl -s http://api:8080/healthz)" ok
check "web healthz" "$(code http://web:3000/healthz)" 200
check "POST ohne Key" "$(code -X POST -H 'Content-Type: application/json' \
  -d '{"text":"ci"}' http://api:8080/notes)" 401
check "POST über web" "$(code -X POST -H 'Content-Type: application/json' \
  -d '{"text":"ci"}' http://web:3000/api/notes)" 201
exit "$fail"
EOF
cat > compose.ci.yaml <<'EOF'
# compose.ci.yaml – CI, only via -f together with compose.yaml
services:
  api:
    ports: !reset []
  web:
    ports: !reset []
  tests:
    image: curlimages/curl:8.23.0
    profiles: [ci]
    entrypoint: ["/bin/sh", "/tests/smoke.sh"]
    volumes:
      - ./tests:/tests:ro
    networks: [frontend]
    depends_on:
      api:
        condition: service_healthy
      web:
        condition: service_healthy
EOF
cat > ci.sh <<'EOF'
#!/usr/bin/env bash
# ci.sh – pipeline locally: own project name, cleanup via trap, exit code of the tests
set -euo pipefail
cd "$(dirname "$0")"
P="ci-$$"
dc() { docker compose -p "$P" -f compose.yaml -f compose.ci.yaml "$@"; }
cleanup() {
  dc down -v --remove-orphans >/dev/null 2>&1 || true
  docker image ls --format '{{.Repository}}:{{.Tag}}' | grep "^$P-" \
    | xargs -r docker rmi >/dev/null 2>&1 || true
}
trap cleanup EXIT
dc up -d --build --wait --quiet-pull >/dev/null 2>&1
dc run --rm tests
EOF
shellcheck ci.sh tests/smoke.sh; echo "Exit: $?"
bash ci.sh; echo "Exit: $?"

Expected (shortened):

Exit: 0
 Container ci-…-tests-run-… Created
✔ api healthz
✔ web healthz
✔ POST ohne Key
✔ POST über web
Exit: 0

Three stumbling blocks: without profiles: [ci], up --wait also starts tests, and its exit 0 makes --wait fail. Because the images are named ${COMPOSE_PROJECT_NAME}-…, every run builds its own ci-… images – cleanup removes those too. And NOTES_API_KEY=… bash ci.sh proves the counter-test: web sends a key that api (from the secret file) doesn’t know.

Save your progress? Sign up for free

Knowledge section

One point per question; answer in one or two sentences.

  1. What distinguishes depends_on: [db] from condition: service_healthy?
  2. Why does db’s healthcheck check with pg_isready -h 127.0.0.1?
  3. What is the .env next to compose.yaml for, and what beats it?
  4. You change POSTGRES_PASSWORD and run up -d. What happens to the password in the database?
  5. Why is compose.override.yaml risky in a team, and what is the alternative?
  6. up -d --wait reports exit code 0. Which two things does that not prove?
  7. Why don’t uid, gid and mode take effect for a secret from file:?
  8. What does internal: true do to a network – and what happens to the ports: of a service that is attached only there?
  9. Why do configs: and secrets: with a file: source need a closer look when deploying to another Docker host?
  10. Why does every CI pipeline need its own project name and a down -v in the trap?

Solutions

  1. The short form only waits until the container has started; with service_healthy, the service only starts once db’s healthcheck reports healthy (Day 5).
  2. During initialization, a temporary server listens only on the Unix socket; without -h, db would be healthy too early, and clients over TCP would get connection refused (Day 5, Day 15).
  3. It provides values for interpolating ${VAR} in the file, not for the container. A variable of the same name in the shell wins (Day 4, Day 15).
  4. Nothing: the image only sets the password with an empty volume. Clients with the new value fail with 28P01 until you run ALTER ROLE (Day 10, Day 15).
  5. Compose loads it automatically and silently without -f, so the same command behaves differently on every machine. Better: compose.dev.yaml only with -f (Day 7, Day 15).
  6. That the ports are reachable and that the application works functionally (for example, that the table exists) – that needs a test from the outside (Day 13, Day 15).
  7. Compose mounts the file via a bind mount; owner and permissions come from the host. According to the docs, Compose only applies the three for the environment: source (Day 10).
  8. Services in the network reach each other, but nothing outside; a service only in an internal network isn’t published, and ports: has no effect (Day 2, Day 15).
  9. The source is resolved on the Docker host that starts the container; the Mac path doesn’t exist on the server. Hence content:/environment: or files on the server (Day 14).
  10. Otherwise parallel runs share containers, networks, volumes and images, and leftovers of an aborted run skew the next one (Day 13).

Finally, clean up:

docker compose down -v --rmi local

Expected (shortened, names and IDs differ):

…
 Image notes-api:2.0 Removed
 Image notes-api:dev Removed
…

Passed? Then you run multiple containers as one system that starts with one command, checks itself and runs the same everywhere – and you find the errors in other people’s Compose files.