BM: Baca dalam Bahasa Melayu
World D1: First Containers
Follow the logs
You will learn: to read what a container printed, and to watch new lines live.
Checked with Docker Engine 29 on 31 Oct 2026
The problem
Your laptop~
- Laptop port 8080 → web port 80
Lunchboxes (containers)
- webrunning
- timerfailed (exit 127)
Frozen packs (images)
- alpine:3.221 layers · 12.9MB · in use
- nginx:1.30-alpine8 layers · 93.5MB · in use
2 containers (1 running), 2 images, 0 lockers.
Your timer box should tick for an hour. It stopped at once: Exited (127). No error on your screen. How do you find out why?
Try it
A box keeps notes of everything it prints: its logs: Everything a container printed while it worked. Read them with docker logs.. Read timer’s notes.
Your laptop~
- Laptop port 8080 → web port 80
Lunchboxes (containers)
- webrunning
- timerfailed (exit 127)
Frozen packs (images)
- alpine:3.221 layers · 12.9MB · in use
- nginx:1.30-alpine8 layers · 93.5MB · in use
2 containers (1 running), 2 images, 0 lockers.
Hint
Typedocker logs timer.Check
The logs end with the real error sh: sleeep: not found. What does it mean?
Pick one answer.
Watch
Your laptop~
- Laptop port 8080 → web port 80
Lunchboxes (containers)
- webrunning
- timerfailed (exit 127)
Frozen packs (images)
- alpine:3.221 layers · 12.9MB · in use
- nginx:1.30-alpine8 layers · 93.5MB · in use
2 containers (1 running), 2 images, 0 lockers.
Every visit to web adds a line. --tail 1 shows only the last one. Add -f (follow) to watch new lines live. Ctrl+C stops watching.
Try it
Visit web with curl localhost:8080. Then read web’s logs and find your visit.
Your laptop~
- Laptop port 8080 → web port 80
Lunchboxes (containers)
- webrunning
- timerfailed (exit 127)
Frozen packs (images)
- alpine:3.221 layers · 12.9MB · in use
- nginx:1.30-alpine8 layers · 93.5MB · in use
2 containers (1 running), 2 images, 0 lockers.
Predict
docker logs -f web is running. You press Ctrl+C. What happens to web?
Pick one answer.
You did it!
You can now read a container’s logs to find the problem.
Go deeper (optional)
Logs are what the app prints to the screen (stdout and stderr). The nginx image sends its log files there too. Handy flags: --tail 20, --since 10m, and -t for times. Logs vanish when you remove the box.
Real rep (optional):
Real mission
docker run -d --name web -p 8080:80 nginx:1.30-alpinedocker logs -f webdocker rm -f web
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Bekas timer anda patut berdetik selama sejam. Ia terus berhenti: Exited (127). Tiada ralat di skrin anda. Macam mana nak tahu sebabnya?
Bekas simpan catatan semua yang ia paparkan: log dia. Baca catatan timer.
docker logs timer.Log itu berakhir dengan ralat sebenar sh: sleeep: not found. Apa maksudnya?
Setiap lawatan ke web tambah satu baris. --tail 1 tunjuk yang terakhir sahaja. Tambah -f (follow) untuk tengok baris baru secara langsung. Ctrl+C berhenti menengok.
Lawat web dengan curl localhost:8080. Kemudian baca log web dan cari lawatan anda.
docker logs -f web sedang berjalan. Anda tekan Ctrl+C. Apa jadi pada web?
Kini anda boleh baca log container untuk cari punca masalah.
You finished this before. Practice is always welcome!
Official docs: docker logs · View container logs
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?