The command after HEALTHCHECK CMD follows the same format as ENTRYPOINT, in either the shell or the exec format. The default value is 0 second (introduced since version 17.05). Failed health check during the startup is not counted. -start-period=: The initialization time of application startup.-retries=: The container status is regarded as unhealthy if the health check fails continuously for a specified number of times.The health check fails if the timeout is exceeded. -timeout=: The timeout for running the health check command.-interval=: The time interval between two health checks.HEALTHCHECK supports the following options: Health check is started automatically after the container is started. Images built by using Dockerfiles that contain HEALTHCHECK instructions can check the health status when instantiating Docker containers. If multiple HEALTHCHECK instructions exist, only the last one takes effect. Note: The HEALTHCHECK can only appear once in the Dockerfile. HEALTHCHECK NONE: If the basic image has a health check instruction, this line can be used to block it.HEALTHCHECK CMD : The command that sets the container health check.This can reflect the real status of the container. The HEALTHCHECK instruction declares the health check command that can be used to determine whether or not the service status of the container master process is normal. The health check configurations of an application can be declared in the Dockerfile. Docker native health check capabilityĭocker introduced the native health check implementation after version 1.12.
Alibaba Cloud Container Service also provides a similar Service health check. Kubernetes provides Liveness and Readness probes to check the health status of the container and its service respectively. For example, a container process is still alive, but cannot respond to user requests because of application deadlock, such problems cannot be discovered by monitoring the process. In many real scenarios, process-level health check alone is far from enough. If the docker run command specifies the restart policy, closed containers can be restarted automatically according to the restart policy. Docker daemon automatically monitors the PID1 process in the container. Process-level health check checks whether or not the process is alive and is the simplest health check for containers. This document introduces the health check of Docker containers. Docker introduced native health check implementation after version 1.12. In a distributed system, the service availability is frequently checked by using the health check to avoid exceptions when being called by other services. Health check mechanism of Docker containers Last Updated: May 14, 2018