Docker HEALTHCHECK vs Kubernetes livenessProbe and readinessProbe
Codemia Knowledge Hub ·
Docker HEALTHCHECK lets the container runtime mark a container as healthy or unhealthy. Kubernetes probes decide whether a Pod should receive traffic (readinessProbe) or be restarted (livenessProbe). If you run in Kubernetes, the probes in the Pod spec are usually the ones that matter operationally.
What Docker HEALTHCHECK does
A HEALTHCHECK is defined in the image or container configuration:
Docker then records whether the container is healthy, starting or unhealthy. It is image-level metadata and runtime behavior inside the Docker ecosystem, useful for:
- plain
docker run - Docker Compose
- local development
- tooling that reads container health state directly
What livenessProbe does
A livenessProbe answers: "Should Kubernetes restart this container because it appears broken?"
If it fails repeatedly, Kubernetes restarts the container.
What readinessProbe does
A readinessProbe answers: "Is this container ready to receive traffic right now?"
If readiness fails, the Pod keeps running but is removed from Service endpoints until it is ready again. Readiness affects traffic; liveness affects restarts.
Why to define probes in the Pod spec
Kubernetes does not treat a Docker HEALTHCHECK in the image as a substitute for explicit probes. If the workload runs in Kubernetes, define health behavior in the Pod spec, where orchestration policy belongs, so deployment-specific health rules stay with the deployment.
startupProbe for slow-booting apps
Use a startupProbe when the application takes a long time to initialize and you do not want liveness checks to kill it early:
This is often a better fix than stretching liveness timings a lot.
Which check to use when
Use Docker HEALTHCHECK when:
- the container is mainly run with Docker tools
- you want image-local health metadata
- you are working outside Kubernetes
Use readinessProbe when:
- the app may be alive but temporarily unable to serve requests
- you want safe rollouts and traffic gating
Use livenessProbe when:
- the app can get stuck in a bad state and should be restarted automatically
Health check mistakes that cause outages or restart loops
- One endpoint for readiness and liveness. A dependency outage may mean "stop sending traffic" but not "restart the process."
- Relying on Docker
HEALTHCHECKalone in Kubernetes. Define probe behavior explicitly. - Aggressive liveness probes. They create restart loops for apps that are merely slow to start; a
startupProbeis often the right fix.
Related reading
- When to use Secrets as opposed to ConfigMaps in Kubernetes?
- Where are helm charts stored locally?
- Where are the Kubernetes kubelet logs located?
- Where can I get a list of Kubernetes API resources and subresources?
- Where are Docker images stored on the host machine?
- Where can I find the sha256 code of a docker image?
- Where helm stores its data on a cluster
- Where is kube-apiserver located
System design interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design a Task Scheduler: solution and walkthrough
- Design a GPU Cluster Scheduler for ML Training: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.