Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Docker HEALTHCHECK vs livenessProbe / readinessProbe

Tags:

The new ability to specify a HEALTHCHECK in a Dockerfile seems redundant with the Kubernetes probe directives. Any advice on what to use when?

like image 374
Kushal Dave Avatar asked Jan 04 '17 23:01

Kushal Dave


People also ask

What is Livenessprobe and Readinessprobe?

Summary. Both liveness & readiness probes are used to control the health of an application. Failing liveness probe will restart the container, whereas failing readiness probe will stop our application from serving traffic.

What does Docker Healthcheck do?

The HEALTHCHECK directive tells Docker how to determine if the state of the container is normal. This was a new directive introduced during Docker 1.12.

Does Kubernetes support Docker Healthcheck?

Update: Since Kubernetes 1.8, the Docker HEALTHCHECK has been disabled explicitly in Kubernetes.

How do you protect slow starting containers from failure restarts?

Protect slow starting containers with startup probes The trick is to set up a startup probe with the same command, HTTP or TCP check, with a failureThreshold * periodSeconds long enough to cover the worse case startup time.


1 Answers

If you use Kubernetes, I'd suggest using only the Kubernetes liveness/readiness checks because Docker healthcheck has not been integrated in the Kubernetes as of now (release 1.12). This means that Kubernetes does not expose the check status in its api server, and the internal system components can not consume this information. Also, Kubernetes distinguishes liveness from readiness checks, so that other components can react differently (e.g., restarting the container vs. removing the pod from the list of endpoints for a service), which the docker HEALTHCHECK currently does not provide.

Update: Since Kubernetes 1.8, the Docker HEALTHCHECK has been disabled explicitly in Kubernetes.

like image 72
Yu-Ju Hong Avatar answered Sep 30 '22 22:09

Yu-Ju Hong