BM: Baca dalam Bahasa Melayu
World D4: Set Meals
Dev vs prod: override files
You will learn: to run one app two ways, with a shared file and small extras.
Checked with Docker Engine 29 on 31 Oct 2026
The problem
Your laptop wants quick edits. The shop’s server wants to stay up by itself. One file can’t say both. Sort each wish.
Drag a card into a box. Or tap the card, then tap the box.
Watch
# compose.override.yaml
services:
web:
volumes:
- ./web:/usr/share/nginx/html:roYour 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.
Shared things stay in compose.yaml. Laptop extras go in compose.override.yaml. Compose reads this override file: A second compose file laid on top of the first. compose.override.yaml loads by itself; others need -f. by itself and lays it on top.
Predict
Two files set the same key. The first says one value, the later file says another. Which one wins?
Pick one answer.
Try it
Start the server version: compose.yaml plus compose.prod.yaml. Name both files with -f, base first.
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.
Hint
docker compose -f compose.yaml -f compose.prod.yaml up -dCheck
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.
Why the old page? With -f, Compose reads only the files you name. No dev mount, so the page comes from the image.
You did it!
You can now run one app two ways: dev and prod.
Go deeper (optional)
How files merge: one value (like image) is replaced. Lists like ports are added together. environment merges by name. volumes merge by the path inside the box. Dry run the mix before you start it: docker compose -f compose.yaml -f compose.prod.yaml config.
Real mission
docker compose configdocker compose -f compose.yaml -f compose.prod.yaml config
0 of 3 steps done · Your ticks are saved.
Bahasa Melayu
Laptop anda mahu suntingan cepat. Server kedai mahu terus hidup sendiri. Satu fail tak boleh kata kedua-duanya. Susun setiap hajat.
# compose.override.yaml
services:
web:
volumes:
- ./web:/usr/share/nginx/html:roBenda yang dikongsi kekal dalam compose.yaml. Tambahan laptop masuk ke compose.override.yaml. Compose baca fail override ini sendiri dan letak di atas.
Dua fail tetapkan kunci yang sama. Fail pertama kata satu nilai, fail kemudian kata nilai lain. Mana yang menang?
Hidupkan versi server: compose.yaml dengan compose.prod.yaml. Namakan kedua-dua fail dengan -f, asas dulu.
docker compose -f compose.yaml -f compose.prod.yaml up -dKenapa laman lama? Dengan -f, Compose baca fail yang anda namakan sahaja. Tiada pasangan folder dev, jadi laman datang dari image.
Kini anda boleh jalankan satu aplikasi dua cara: dev dan prod.
You finished this before. Practice is always welcome!
Official docs: Merge Compose files · Use Compose in production · docker compose -f
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?