In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly talks about "what is the health check of Docker container". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the health check of Docker containers"?
Docker container health check refers to using the HEALTHCHECK directive in Dockerfile to check the running status of the container and displaying healthy/unhealthy in the STATUS column of docker ps.
There are two formats for HEALTHCHECK instructions:
HEALTHCHECK [OPTIONS] CMD command (check the health of the container by running the command inside the container)
HEALTHCHECK NONE (disable inheriting any health check from the underlying image)
The HEALTHCHECK directive tells Docker how to test a container to see if it is still working. This can detect situations such as when the web server is stuck in an infinite loop and cannot handle new connections, even if the server process is still running.
When the container specifies a health check, it has a healthy state in addition to its normal state. This state is initially starting. As soon as the health check passes, it will revert to healthy (no matter what state it was in). After a certain number of consecutive failures, it becomes unhealthy.
The options that can appear before CMD are:
-- interval=DURATION (default: 30s)
-- timeout=DURATION (default: 30s)
-- start-period=DURATION (default: 0s)
-- retries=N (default: 3)
The running status check is first run within interval seconds after the container is started, and then run again within interval seconds after the previous check is completed.
If a status check takes more than timeout seconds, the check is considered a failure.
The container's running status check fails retries times before it is considered unhealthy.
Start period provides initialization time for containers that need time to start. Probe failures during this period will not be counted as the maximum number of retries. However, if the health check is successful during startup, the container is considered to have been started and all consecutive failures will be counted as the maximum number of retries.
There can be only one HEALTHCHECK instruction in Dockerfile. If more than one is listed, only the last HEALTHCHECK will take effect.
The command after the CMD keyword can be a shell command (such as HEALTHCHECK CMD / bin/check-running) or an exec array (like other Dockerfile commands, see ENTRYPOINT for more information).
The exit status of the command indicates the health status of the container. Possible values are:
0: successful-the container is running well and can be used
1: unhealthy-the container does not work properly
2: reserved-do not use this exit code
For example, check every five minutes or so to see if the web server can serve the site's home page in three seconds:
HEALTHCHECK-- interval=5m-- timeout=3s\ CMD curl-f http://localhost/ | | exit 1
To help detect debug failures, any output text (UTF-8 encoding) written by command on stdout or stderr will be stored in a healthy state and can be queried through docker inspect. Such output should be kept short (currently only the first 4096 bytes are stored).
When the health state of the container changes, a health_status event with the new state is generated.
At this point, I believe you have a deeper understanding of "what is the health check of Docker containers". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Problem: root@anxxxx-prod1:~# df-hFilesystem Size Used Avail Use%
© 2024 shulou.com SLNews company. All rights reserved.