BM: Baca dalam Bahasa Melayu
World D2: Recipes
Build context and .dockerignore
You will learn: what docker build sends to the kitchen, and how to leave secrets at home.
Checked with Docker Engine 29 on 31 Oct 2026
The problem
Your laptop~/diary
- 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.
You shipped your diary site. A friend opens /notes.txt. Your secret notes are online! How did they get in?
Watch
Tap the line where your folder is sent.
0 of 1 found
docker build . sends the whole folder to the kitchen. That folder is the build context: The folder you send to the kitchen when you build. COPY can only take from it.. COPY . copies all of it, notes too.
Try it
Send it to the kitchen, or leave it at home?
Drag a card into a box. Or tap the card, then tap the box.
Try it
A .dockerignore: A list of files to leave at home. They are never sent to the build. file lists what stays home. Make one, rebuild as diary:1.1, run it, then ask for /notes.txt.
Your laptop~/diary
- 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.
Hint
Start withecho "notes.txt" > .dockerignore.Predict
.dockerignore lists .env. The recipe says COPY . .. Is .env in the image?
Pick one answer.
Check
Good .dockerignore lines? Swipe right for yes, left for “needs work”.
Swipe right for good, left for needs work. Or use the buttons.
.gitYou did it!
You can now choose what goes to the kitchen with .dockerignore.
Go deeper (optional)
A line starting with ! brings a file back: *.md then !README.md. You can list Dockerfile and .dockerignore too; the build still reads them. A smaller context also helps the cache, because fewer files can change.
Real mission
0 of 3 steps done · Your ticks are saved.
Bahasa Melayu
Anda sudah lancar laman diari. Kawan anda buka /notes.txt. Nota rahsia anda ada di internet! Macam mana ia masuk?
docker build . hantar seluruh folder ke dapur. Folder itu ialah konteks binaan. COPY . salin semuanya, nota pun sekali.
Hantar ke dapur, atau tinggal di rumah?
Fail .dockerignore senaraikan apa yang tinggal di rumah. Buat satu, bina semula sebagai diary:1.1, jalankan, kemudian minta /notes.txt.
echo "notes.txt" > .dockerignore..dockerignore senaraikan .env. Resepi tulis COPY . .. Adakah .env dalam image?
Baris .dockerignore yang bagus? Leret ke kanan untuk ya, ke kiri untuk “perlu dibaiki”.
Kini anda boleh pilih apa yang dihantar ke dapur dengan .dockerignore.
You finished this before. Practice is always welcome!
Official docs: Docker docs: Build context · Docker docs: .dockerignore files
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?