BM: Baca dalam Bahasa Melayu
World D3: Lockers & Phone Lines
Never bake in secrets
You will learn: why a password in a Dockerfile leaks, and how to hand it over at run time.
Checked with Docker Engine 29 on 31 Oct 2026
The problem
Your laptop~/shop
- No open hatches
Lunchboxes (containers)
- No containers yet
Frozen packs (images)
- nginx:1.30-alpine8 layers · 93.5MB
0 containers (0 running), 1 images, 0 lockers.
The recipe says ENV DB_PASSWORD=kancil123. Docker even warns: SecretsUsedInArgOrEnv. Now every box from this image knows the password.
Watch
A secret: The locked spice box: private info like a token. Never put it in code. is the locked spice box. Never stir it into the recipe. Hand it over only when the dish is served. Sort these.
Drag a card into a box. Or tap the card, then tap the box.
Predict
You push shop:1.0 to a public registry. Who can read the password?
Pick one answer.
Check
This is docker history for shop:1.0. Tap the line that leaks.
0 of 1 found
Every recipe line stays in the image’s history. Anyone can read it.
Try it
Start db. Hand it the password from db.env, at run time.
Your laptop~/shop
- No open hatches
Lunchboxes (containers)
- No containers yet
Frozen packs (images)
- postgres:18-alpine9 layers · 433MB
0 containers (0 running), 1 images, 0 lockers.
Hint
cat db.env shows the card. Then --env-file db.env.Check
Safe habit, or a leak?
Swipe right for good, left for needs work. Or use the buttons.
Put .env files in .gitignore.
You did it!
You can now keep secrets out of your images.
Go deeper (optional)
Run-time env vars still show in docker inspect. Compose secrets arrive as files in /run/secrets.
Where the story breaks: a locker isn’t truly outside. Volumes sit on the same disk, or in Docker Desktop’s VM. Lose the disk, lose the locker. Phone lines are only software. And an env var is no locked box.
Real mission
docker history --no-trunc <your-image>git check-ignore .env
0 of 3 steps done · Your ticks are saved.
Bahasa Melayu
Resepi tulis ENV DB_PASSWORD=kancil123. Docker pun beri amaran: SecretsUsedInArgOrEnv. Kini setiap bekas daripada image ini tahu kata laluan itu.
Secret (rahsia) ialah kotak rempah berkunci. Jangan kacau ke dalam resepi. Serahkan hanya bila hidangan dihidang. Susun yang ini.
Anda push shop:1.0 ke registry awam. Siapa boleh baca kata laluan itu?
Setiap baris resepi kekal dalam sejarah image. Sesiapa boleh baca.
Mulakan db. Serahkan kata laluan dari db.env, semasa run.
cat db.env tunjuk kad itu. Kemudian --env-file db.env.Tabiat selamat, atau bocor?
Kini anda boleh jauhkan rahsia dari image anda.
You finished this before. Practice is always welcome!
Official docs: Docker docs: SecretsUsedInArgOrEnv · Docker docs: Build secrets · Docker docs: Secrets in Compose
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?