health check บอก Docker (หรือ orchestrator) ว่าจะระบุได้อย่างไรว่าแอปพลิเคชันใน container กำลัง ทำงานได้จริง ไม่ใช่แค่รันอยู่ process ของ container อาจทำงานอยู่ในขณะที่แอปพังไปแล้ว (ค้าง เชื่อมต่อ database ไม่ได้) — health check ตรวจจับสิ่งนี้เพื่อให้แพลตฟอร์มสามารถตอบสนองได้
การกำหนด health check
# in a Dockerfile
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# → Docker runs this command periodically; exit 0 = healthy, non-zero = unhealthy
[, , , ]
