乐闻世界logo
搜索文章和话题

What is the configuration and usage of Docker health checks?

2月17日 23:47

Docker health checks are used to monitor the health status of applications within containers. Defined via the HEALTHCHECK instruction in a Dockerfile or using the docker run --health-cmd parameter. The check command is executed periodically, and health status is determined by the exit code: 0 means healthy, 1 means unhealthy, 2 means reserve status. Related parameters: --interval (check interval, default 30s), --timeout (timeout, default 30s), --retries (failure retry count, default 3), --start-period (startup grace period). The docker ps command displays health status (healthy, unhealthy, starting). When health checks fail, Swarm automatically restarts unhealthy containers.

标签:Docker