BM: Baca dalam Bahasa Melayu
World D3: Lockers & Phone Lines
Where did my data go?
You will learn: why files saved inside a container vanish.
Checked with Docker Engine 29 on 31 Oct 2026
The problem
Your laptop~
- No open hatches
Lunchboxes (containers)
- kedairunning
Frozen packs (images)
- alpine:3.221 layers · 12.9MB
- nginx:1.30-alpine8 layers · 93.5MB · in use
1 containers (1 running), 2 images, 0 lockers.
Aina kept today’s orders inside her container. Then she swapped it for a fresh one. The orders vanished. Where did they go?
Watch
Tap each point on the timeline.
Every container gets its own thin top layer. This is the writable layer: The container's own thin top layer. Your changes land there. docker rm throws it away.. Tap each step to follow orders.txt.
Try it
Restart kedai. Then check that orders.txt is still there.
Your laptop~
- No open hatches
Lunchboxes (containers)
- kedairunning
Frozen packs (images)
- alpine:3.221 layers · 12.9MB
- nginx:1.30-alpine8 layers · 93.5MB · in use
1 containers (1 running), 2 images, 0 lockers.
Hint
docker restart kedai, then docker exec kedai cat /orders.txt.Predict
Guess first, then run it. Does the file survive?
Where does each file live? Guess what stays, then run it.
$ docker run -d --name kedai nginx:1.30-alpineQuestion 1 of 2
Lunchbox: container kedai
- Inside the lunchbox (writable layer)
/app/orders.txt
Outside the lunchbox
Next, you run:
Restart the container.
$ docker restart kedaiPick Stays or Gone for every file first.
Check
After docker rm, what is gone and what stays?
Drag a card into a box. Or tap the card, then tap the box.
Check
Your shop app saves photo uploads in /app/uploads. How do you keep them safe?
Pick one answer.
You did it!
You can now explain why files inside a container vanish.
Go deeper (optional)
docker diff lists what changed in the writable layer. A means added, C changed, D deleted.
Real rep (optional), on your own Docker or in Codespaces:
Real mission
docker run -d --name box alpine:3.22 sleep 600docker exec box sh -c "echo hi > /note.txt"docker rm -f boxdocker run --rm alpine:3.22 cat /note.txt
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Aina simpan pesanan hari ini dalam container. Lepas itu dia tukar dengan container baru. Pesanan itu lesap. Ke mana perginya?
Setiap container ada lapisan atas yang nipis. Inilah writable layer (lapisan tulis). Tekan setiap langkah untuk ikut orders.txt.
Restart kedai. Kemudian semak orders.txt masih ada.
docker restart kedai, kemudian docker exec kedai cat /orders.txt.Teka dulu, kemudian jalankan. Adakah fail itu kekal?
Selepas docker rm, apa yang hilang dan apa yang kekal?
Aplikasi kedai anda simpan gambar yang dimuat naik dalam /app/uploads. Macam mana nak jaga gambar itu?
Kini anda boleh terangkan kenapa fail dalam container boleh hilang.
You finished this before. Practice is always welcome!
Official docs: Docker docs: Storage · Docker docs: docker container diff
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?