World map

 

BM: Baca dalam Bahasa Melayu

World D4: Set Meals

Optional extras: profiles

You will learn: to keep extra dishes off until you ask for them.

Checked with Docker Engine 29 on 31 Oct 2026

The problem

web, api and db start. The cache in the same file does not. Docker transcript: $ docker compose up -d [+] up 5/5 ✔ Network kedai-kancil_default Created 0.1s ✔ Volume kedai-kancil_db-data Created 0.0s ✔ Container kedai-kancil-web-1 Started 0.3s ✔ Container kedai-kancil-api-1 Started 0.3s ✔ Container kedai-kancil-db-1 Started 0.3s $ docker compose ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS kedai-kancil-api-1 kedai-kancil-api "docker-entrypoint.s…" api 3 seconds ago Up 3 seconds 3000/tcp kedai-kancil-db-1 postgres:18-alpine "docker-entrypoint.s…" db 3 seconds ago Up 3 seconds 5432/tcp kedai-kancil-web-1 kedai-kancil-web "/docker-entrypoint.…" web 3 seconds ago Up 3 seconds 0.0.0.0:8080->80/tcp

Your laptop~/kedai-kancil

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • kedai-kancil-api:latest6 layers · 244MB
  • kedai-kancil-web:latest9 layers · 92.6MB
  • nginx:1.30-alpine8 layers · 93.5MB
  • node:24-alpine4 layers · 244MB
  • postgres:18-alpine9 layers · 433MB
  • redis:8-alpine7 layers · 162MB

0 containers (0 running), 6 images, 0 lockers.

The cache is right there in compose.yaml. You ran docker compose up -d. So why is it not running?

Watch

  cache:
    image: redis:8-alpine
    profiles: [cache]

A side dish comes only when you ask for it. That is a profile: A side dish: a service that starts only when you ask, with --profile or by its name.. A dish with a profile stays off. You turn it on when you need it. Sort the dishes.

Drag a card into a box. Or tap the card, then tap the box.

      Try it

      Order the side dish too. Turn on the cache profile.

      Your laptop~/kedai-kancil

      • Laptop port 8080 → kedai-kancil-web-1 port 80

      Lunchboxes (containers)

      • kedai-kancil-api-1running
        from kedai-kancil-api kedai-kancil_default
      • kedai-kancil-db-1running
        from postgres:18-alpine kedai-kancil_default kedai-kancil_db-data → /var/lib/postgresql
      • kedai-kancil-web-1running
        from kedai-kancil-web 8080→80 kedai-kancil_default

      Frozen packs (images)

      • kedai-kancil-api:latest6 layers · 244MB · in use
      • kedai-kancil-web:latest9 layers · 92.6MB · in use
      • nginx:1.30-alpine8 layers · 93.5MB
      • node:24-alpine4 layers · 244MB
      • postgres:18-alpine9 layers · 433MB · in use
      • redis:8-alpine7 layers · 162MB

      Lockers (volumes)

      • kedai-kancil_db-data24 files · used by kedai-kancil-db-1

      Phone lines (networks)

      • kedai-kancil_defaultkedai-kancil-api-1 ↔ kedai-kancil-db-1 ↔ kedai-kancil-web-1

      3 containers (3 running), 6 images, 1 lockers.

      Predict

      No --profile at all. You type docker compose up -d cache. What happens?

      Pick one answer.

      Check

      Plain down removes web, api and db. The cache keeps running, and so does its phone line. Docker transcript: $ docker compose --profile cache up -d [+] up 6/6 ✔ Network kedai-kancil_default Created 0.1s ✔ Volume kedai-kancil_db-data Created 0.0s ✔ Container kedai-kancil-web-1 Started 0.3s ✔ Container kedai-kancil-api-1 Started 0.3s ✔ Container kedai-kancil-db-1 Started 0.3s ✔ Container kedai-kancil-cache-1 Started 0.3s $ docker compose down [+] down 3/4 ✔ Container kedai-kancil-db-1 Removed 0.2s ✔ Container kedai-kancil-api-1 Removed 10.2s ✔ Container kedai-kancil-web-1 Removed 0.2s ! Network kedai-kancil_default Resource is still in use 0.0s $ docker compose ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS kedai-kancil-cache-1 redis:8-alpine "docker-entrypoint.s…" cache 16 seconds ago Up 16 seconds 6379/tcp

      Your laptop~/kedai-kancil

      • No open hatches

      Lunchboxes (containers)

      • No containers yet

      Frozen packs (images)

      • kedai-kancil-api:latest6 layers · 244MB
      • kedai-kancil-web:latest9 layers · 92.6MB
      • nginx:1.30-alpine8 layers · 93.5MB
      • node:24-alpine4 layers · 244MB
      • postgres:18-alpine9 layers · 433MB
      • redis:8-alpine7 layers · 162MB

      0 containers (0 running), 6 images, 0 lockers.

      Careful at closing time. Plain down only clears dishes without a profile. Add --profile cache to clear the side dish too.

      You did it!

      You can now keep extra dishes off until you ask for them.

      Go deeper (optional)

      COMPOSE_PROFILES=cache docker compose up -d does the same as the flag. Turn on two with --profile cache --profile debug. Good side dishes: debug tools, an admin page, a job that loads test data. Profile names use letters, digits, _, . and -.

      Real mission

      1. docker compose config --services
      2. docker compose --profile cache config --services

      0 of 3 steps done · Your ticks are saved.