BM: Baca dalam Bahasa Melayu
World D2: Recipes
HEALTHCHECK: is it alive?
You will learn: to let Docker check that your app still answers, not just that it runs.
Checked with Docker Engine 29 on 31 Oct 2026
The problem
docker ps says your box is Up. But every page shows an error. Is it healthy?
Pick one answer.
Watch
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.
A HEALTHCHECK: A small test Docker runs again and again: is the app still answering? knocks every 5 seconds. Here it asks for /health, which does not exist. After 3 misses in a row, the status says unhealthy.
Try it
Build a check that knocks on the home page every 10 seconds.
Tap the pieces in the right order.
Try it
This recipe checks the home page. Build it, run it as web, wait a little, then look.
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
The first knock comes after 5 seconds.sleep 6 waits.Predict
web turns unhealthy. What does plain Docker do about it?
Pick one answer.
You did it!
You can now add a HEALTHCHECK and read the health status.
Go deeper (optional)
Defaults: every 30s, 30s timeout, 3 retries. --start-period gives a slow app time to wake up. Compose can wait for service_healthy (World D4). Kubernetes ignores HEALTHCHECK and uses its own probes (Part 3). Check / or a small /health page, never anything slow.
Real mission
docker ps
0 of 3 steps done · Your ticks are saved.
Bahasa Melayu
docker ps kata bekas anda Up. Tapi setiap laman tunjuk ralat. Adakah ia sihat?
HEALTHCHECK mengetuk setiap 5 saat. Di sini ia minta /health, yang tak wujud. Selepas 3 kali gagal berturut-turut, statusnya jadi unhealthy.
Bina baris health check yang ketuk laman utama setiap 10 saat.
Resepi ini semak laman utama. Bina, jalankan sebagai web, tunggu sekejap, kemudian tengok.
sleep 6 menunggu.web jadi unhealthy. Apa yang Docker biasa buat?
Kini anda boleh tambah HEALTHCHECK dan baca status kesihatan.
You finished this before. Practice is always welcome!
Official docs: Dockerfile reference: HEALTHCHECK · docker ps
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?