{"id":1320,"date":"2024-07-23T12:20:35","date_gmt":"2024-07-23T12:20:35","guid":{"rendered":"https:\/\/dockerpros.com\/?post_type=glossary&#038;p=1320"},"modified":"2024-07-23T12:23:24","modified_gmt":"2024-07-23T12:23:24","slug":"dockerfile-healthcheck","status":"publish","type":"glossary","link":"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile-healthcheck\/","title":{"rendered":"HEALTHCHECK Dockerfile"},"content":{"rendered":"<h1>Understanding Dockerfile HEALTHCHECK: Ensuring Container Health in a Microservices World<\/h1>\n<p>In the realm of containerization, a <code><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> instruction in a <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> acts as a mechanism to determine the health status of a running <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. By integrating health checks, developers can automate the monitoring of containerized applications, ensuring that they are responding as expected and can be seamlessly managed within <span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\" target=\"_blank\">orchestration<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Orchestration refers to the automated management and coordination of complex systems and services. It optimizes processes by integrating various components, ensuring efficient operation and resource utilization.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> platforms like <span class=\"glossaryai-tooltip glossary-term-656\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\" target=\"_blank\">Kubernetes<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications, enhancing resource efficiency and resilience.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and <span class=\"glossaryai-tooltip glossary-term-655\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-swarm\/\" target=\"_blank\">Docker Swarm<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Swarm is a container orchestration tool that enables the management of a cluster of Docker engines. It simplifies scaling and deployment, ensuring high availability and load balancing across services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-swarm\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. This article delves into the intricacies of the <code><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> instruction, exploring its importance, implementation, best practices, and real-world applications.<\/p>\n<h2>The Importance of Health Checks<\/h2>\n<p>The increasing adoption of microservices architecture has led to a surge in containerized applications. Each microservice operates independently, leading to challenges in maintaining overall system health. Here, the <code><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> instruction becomes critical. It allows developers to define commands that Docker executes to assess the container&#8217;s health. A failing <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can trigger automated recovery mechanisms, such as restarting the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> or rerouting traffic, thereby enhancing application resilience and reliability.<\/p>\n<h3>Why Health Checks Matter<\/h3>\n<ol>\n<li>\n<p><strong>Automated Recovery<\/strong>: Containers can automatically restart when they fail health checks, minimizing downtime and ensuring availability.<\/p>\n<\/li>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-697\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/load-balancing\/\" target=\"_blank\">Load Balancing<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Load balancing is a critical network management technique that distributes incoming traffic across multiple servers. This ensures optimal resource utilization, minimizes response time, and enhances application availability.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/load-balancing\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/strong>: In orchestrated environments, only healthy containers receive traffic, which optimizes resource utilization and improves user experience.<\/p>\n<\/li>\n<li>\n<p><strong>Centralized Monitoring<\/strong>: Health checks can be integrated with monitoring tools, providing insights into application performance and system health.<\/p>\n<\/li>\n<li>\n<p><strong>Operational Efficiency<\/strong>: Developers can leverage health checks to ensure that their containers are not only running but also functioning correctly, reducing the need for manual oversight.<\/p>\n<\/li>\n<\/ol>\n<h2>Implementing the HEALTHCHECK Instruction<\/h2>\n<p>The <code><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> instruction is defined in the <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and is composed of several key components: the command to be executed, optional interval and timeout settings, retries, and start period. Here is the basic syntax:<\/p>\n<pre><code class=\"language-Dockerfile\"><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> [OPTIONS] <span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> command<\/code><\/pre>\n<h3>Core Options<\/h3>\n<ol>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/strong>: This specifies the command that Docker will <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to check the health of the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. The command should return a status code: <code>0<\/code> for healthy, <code>1<\/code> for unhealthy, and <code>2<\/code> for unknown.<\/p>\n<\/li>\n<li>\n<p><strong>OPTIONS<\/strong>: Several options can modify the behavior of the <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<ul>\n<li><strong>&#8211;interval<\/strong>: Sets the time between health checks (default is 30 seconds).<\/li>\n<li><strong>&#8211;timeout<\/strong>: Defines the time to wait for the <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to complete (default is 30 seconds).<\/li>\n<li><strong>&#8211;retries<\/strong>: Specifies how many consecutive failures are needed before considering the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> unhealthy (default is 3).<\/li>\n<li><strong>&#8211;start-period<\/strong>: Provides a grace period for your <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to initialize before starting health checks.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>Example of a HEALTHCHECK<\/h3>\n<p>Here is an example <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> with a <code><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> instruction:<\/p>\n<pre><code class=\"language-Dockerfile\">FROM nginx:latest\n\n<span class=\"glossaryai-tooltip glossary-term-673\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/copy\/\" target=\"_blank\">COPY<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">COPY is a command in computer programming and data management that facilitates the duplication of files or data from one location to another, ensuring data integrity and accessibility.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/copy\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> .\/html \/usr\/share\/nginx\/html\n\n<span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --interval=30s --timeout=10s --retries=3 <span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> curl --fail http:\/\/localhost\/ || exit 1<\/code><\/pre>\n<p>In this example, the <code><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> command attempts to access the web server running on <code>localhost<\/code>. If it fails to get a response, it will retry the <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> up to three times before marking the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> as unhealthy.<\/p>\n<h2>Best Practices for Effective Health Checks<\/h2>\n<h3>1. Choose Meaningful Checks<\/h3>\n<p>The <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> should provide meaningful information about the application&#8217;s state. Instead of performing superficial checks, such as confirming that the process is running, developers should verify that the application can respond to requests appropriately.<\/p>\n<h3>2. Minimize Resource Consumption<\/h3>\n<p>Health checks should be lightweight and consume minimal resources. Avoid performing complex operations or database queries, as these can impose additional loads on the application.<\/p>\n<h3>3. Set Appropriate Timeouts and Intervals<\/h3>\n<p>The <code>interval<\/code>, <code>timeout<\/code>, and <code>retries<\/code> settings should align with the application&#8217;s startup time and expected response time. For applications that require more time to initialize, a longer <code>start-period<\/code> can help avoid false negatives during startup.<\/p>\n<h3>4. Use Specific Commands<\/h3>\n<p>Instead of generic commands like <code>ping<\/code> or <code>curl<\/code>, consider using commands tailored to your application&#8217;s functionality. For example, an <span class=\"glossaryai-tooltip glossary-term-1249\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/api\/\" target=\"_blank\">API<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An API, or Application Programming Interface, enables software applications to communicate and interact with each other. It defines protocols and tools for building software and facilitating integration.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/api\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> might benefit from a specific endpoint check, while a database <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> could validate the database&#8217;s responsiveness.<\/p>\n<h3>5. Implement Graceful Shutdowns<\/h3>\n<p>When a <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> fails, ensure that the application can shut down gracefully. This means finishing ongoing requests and closing resources properly before the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is killed.<\/p>\n<h2>Advanced Use Cases of HEALTHCHECK<\/h2>\n<h3>1. Health Checks for Stateful Applications<\/h3>\n<p>Stateful applications, such as databases and message queues, can benefit significantly from health checks. For instance, a PostgreSQL <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can execute a command to validate that the database is accepting connections:<\/p>\n<pre><code class=\"language-Dockerfile\"><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --interval=10s --timeout=5s --retries=3 <span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> pg_isready || exit 1<\/code><\/pre>\n<p>In this example, <code>pg_isready<\/code> checks the database&#8217;s readiness state. If the database is down or unreachable, it will be marked as unhealthy.<\/p>\n<h3>2. Multi-Container Applications<\/h3>\n<p>In multi-container applications, health checks can be integrated across various services. For instance, if a front-end <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> relies on a back-end <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, the <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> for the front-end can include a check for the back-end&#8217;s health:<\/p>\n<pre><code class=\"language-Dockerfile\"><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --interval=15s --timeout=5s <span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> curl --fail http:\/\/backend_service:5000\/health || exit 1<\/code><\/pre>\n<p>This ensures that the front-end only serves traffic if the back-end is operational.<\/p>\n<h3>3. Monitoring Third-Party Services<\/h3>\n<p>In cases where your application interfaces with third-party APIs, you might also want to implement health checks for those dependencies. For example, periodically checking the availability of a payment gateway can help prevent transactions from failing unexpectedly.<\/p>\n<pre><code class=\"language-Dockerfile\"><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --interval=1m --timeout=10s <span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> curl --fail https:\/\/api.paymentgateway.com\/status || exit 1<\/code><\/pre>\n<h3>4. Custom Health Check Scripts<\/h3>\n<p>In complex scenarios, it may be beneficial to create custom <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> scripts that aggregate various health metrics or perform multiple checks. For instance, a script could validate application logs for errors in addition to checking <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> availability.<\/p>\n<pre><code class=\"language-Dockerfile\"><span class=\"glossaryai-tooltip glossary-term-673\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/copy\/\" target=\"_blank\">COPY<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">COPY is a command in computer programming and data management that facilitates the duplication of files or data from one location to another, ensuring data integrity and accessibility.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/copy\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> .\/healthcheck.sh \/usr\/local\/bin\/healthcheck.sh\n<span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">RUN<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> chmod +x \/usr\/local\/bin\/healthcheck.sh\n\n<span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> <span class=\"glossaryai-tooltip glossary-term-670\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\" target=\"_blank\">CMD<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">CMD, or Command Prompt, is a command-line interpreter in Windows operating systems. It allows users to execute commands, automate tasks, and manage system files through a text-based interface.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/cmd\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> \/usr\/local\/bin\/healthcheck.sh<\/code><\/pre>\n<h2>Health Checks in Orchestrated Environments<\/h2>\n<p>The significance of health checks is amplified in orchestrated environments like <span class=\"glossaryai-tooltip glossary-term-656\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\" target=\"_blank\">Kubernetes<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications, enhancing resource efficiency and resilience.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and <span class=\"glossaryai-tooltip glossary-term-655\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-swarm\/\" target=\"_blank\">Docker Swarm<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Swarm is a container orchestration tool that enables the management of a cluster of Docker engines. It simplifies scaling and deployment, ensuring high availability and load balancing across services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-swarm\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. These platforms rely heavily on the health status of containers to manage <span class=\"glossaryai-tooltip glossary-term-696\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/scaling\/\" target=\"_blank\">scaling<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Scaling refers to the process of adjusting the capacity of a system to accommodate varying loads. It can be achieved through vertical scaling, which enhances existing resources, or horizontal scaling, which adds additional resources.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/scaling\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, <span class=\"glossaryai-tooltip glossary-term-697\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/load-balancing\/\" target=\"_blank\">load balancing<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Load balancing is a critical network management technique that distributes incoming traffic across multiple servers. This ensures optimal resource utilization, minimizes response time, and enhances application availability.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/load-balancing\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, and failover mechanisms.<\/p>\n<h3>Kubernetes<\/h3>\n<p>In <span class=\"glossaryai-tooltip glossary-term-656\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\" target=\"_blank\">Kubernetes<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications, enhancing resource efficiency and resilience.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, the concept of readiness and liveness probes closely mirrors Docker\u2019s health checks. A liveness probe determines if the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is running, while a readiness probe indicates whether the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is ready to handle requests. <\/p>\n<p>Here\u2019s a brief example of a liveness probe in a <span class=\"glossaryai-tooltip glossary-term-656\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\" target=\"_blank\">Kubernetes<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications, enhancing resource efficiency and resilience.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/kubernetes\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> deployment manifest:<\/p>\n<pre><code class=\"language-yaml\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: my-app\nspec:\n  replicas: 3\n  template:\n    spec:\n      containers:\n      - name: my-container\n        <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>: my-image\n        livenessProbe:\n          httpGet:\n            path: \/health\n            <span class=\"glossaryai-tooltip glossary-term-677\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/port\/\" target=\"_blank\">port<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A PORT is a communication endpoint in a computer network, defined by a numerical identifier. It facilitates the routing of data to specific applications, enhancing system functionality and security.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/port\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>: 8080\n          initialDelaySeconds: 30\n          periodSeconds: 10<\/code><\/pre>\n<p>The configuration above checks the <code>\/health<\/code> endpoint every 10 seconds after an initial delay, ensuring that the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">container<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is still alive.<\/p>\n<h3>Docker Swarm<\/h3>\n<p>In <span class=\"glossaryai-tooltip glossary-term-655\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-swarm\/\" target=\"_blank\">Docker Swarm<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Swarm is a container orchestration tool that enables the management of a cluster of Docker engines. It simplifies scaling and deployment, ensuring high availability and load balancing across services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-swarm\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, health checks work similarly. A failing <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can trigger a restart of the <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Service refers to the act of providing assistance or support to fulfill specific needs or requirements. In various domains, it encompasses customer service, technical support, and professional services, emphasizing efficiency and user satisfaction.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, allowing for seamless recovery from transient failures. <\/p>\n<h3>Integration with Monitoring Tools<\/h3>\n<p>Integrating health checks with monitoring tools like Prometheus or Grafana can provide a comprehensive view of your system&#8217;s health. You can visualize <span class=\"glossaryai-tooltip glossary-term-698\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\" target=\"_blank\">health check<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A health check is a systematic evaluation of an individual's physical and mental well-being, often involving assessments of vital signs, medical history, and lifestyle factors to identify potential health risks.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/health-check\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> results, set up alerts based on failures, and gain insights into overall system performance.<\/p>\n<h2>Conclusion<\/h2>\n<p>The <code><span class=\"glossaryai-tooltip glossary-term-680\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\" target=\"_blank\">HEALTHCHECK<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">HEALTHCHECK is a Docker directive used to monitor container health by executing specified commands at defined intervals. It enhances reliability by enabling automatic restarts for failing services.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/healthcheck\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> instruction in <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> serves as a fundamental pillar for maintaining the health of containerized applications. By leveraging health checks effectively, developers can automate recovery processes, enhance application resilience, and ensure optimal performance in dynamic environments. <\/p>\n<p>As microservices continue to dominate software architecture, mastering health checks is not merely an optional enhancement; it&#8217;s a critical skill for developers and DevOps professionals alike. By applying the best practices and use cases discussed in this article, teams can build robust, reliable, and self-healing applications that thrive in the ever-evolving landscape of cloud-native computing.<\/p>","protected":false},"excerpt":{"rendered":"<p>The `HEALTHCHECK` instruction in a <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> permet aux d\u00e9veloppeurs de d\u00e9finir une commande qui teste l'\u00e9tat de sant\u00e9 du conteneur. Cela aide \u00e0 s'assurer que les services fonctionnent correctement, facilitant ainsi la r\u00e9cup\u00e9ration et la surveillance automatis\u00e9es.<\/p>","protected":false},"author":1,"featured_media":1955,"parent":0,"template":"","glossary-cat":[],"class_list":["post-1320","glossary","type-glossary","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Dockerfile HEALTHCHECK - Dockerpros<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile-healthcheck\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dockerfile HEALTHCHECK - Dockerpros\" \/>\n<meta property=\"og:description\" content=\"The `HEALTHCHECK` instruction in a Dockerfile enables developers to define a command that tests the container&#039;s health. It helps ensure that services are running correctly, facilitating automated recovery and monitoring.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile-healthcheck\/\" \/>\n<meta property=\"og:site_name\" content=\"Dockerpros\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-23T12:23:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/\",\"url\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/\",\"name\":\"Dockerfile HEALTHCHECK - Dockerpros\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg\",\"datePublished\":\"2024-07-23T12:20:35+00:00\",\"dateModified\":\"2024-07-23T12:23:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#primaryimage\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg\",\"width\":800,\"height\":600,\"caption\":\"dockerfile-healthcheck-2\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dockerpros.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Glossary\",\"item\":\"https:\/\/dockerpros.com\/fr\/wiki\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Dockerfile HEALTHCHECK\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dockerpros.com\/#website\",\"url\":\"https:\/\/dockerpros.com\/\",\"name\":\"Dockerpros\",\"description\":\"DockerPros \u2013 Your Ultimate Docker Resource Hub\",\"publisher\":{\"@id\":\"https:\/\/dockerpros.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dockerpros.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dockerpros.com\/#organization\",\"name\":\"Dockerpros\",\"url\":\"https:\/\/dockerpros.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"width\":532,\"height\":114,\"caption\":\"Dockerpros\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dockerfile HEALTHCHECK - Dockerpros\n\nThe HEALTHCHECK directive is a new feature introduced in Docker 1.12. It allows you to check the health status of a container. This directive is used to determine if a container is functioning correctly or not. It is particularly useful for detecting issues such as a web server that is stuck in an infinite loop and unable to handle new connections, even though the container is still running.\n\nThe HEALTHCHECK directive has the following syntax:\n\n```\nHEALTHCHECK [OPTIONS] CMD command\n```\n\nThe available options are:\n\n- `--interval=DURATION` (default: 30s): The time interval between health checks.\n- `--timeout=DURATION` (default: 30s): The maximum time to wait for the health check command to complete.\n- `--start-period=DURATION` (default: 0s): The initialization time during which the health check failures are ignored.\n- `--retries=N` (default: 3): The number of consecutive failures needed to consider the container as unhealthy.\n\nThe health check command can be any valid command that returns a zero exit code for success and a non-zero exit code for failure. For example, you can use a curl command to check if a web server is responding correctly:\n\n```\nHEALTHCHECK --interval=5m --timeout=3s \\\n  CMD curl -f http:\/\/localhost\/ || exit 1\n```\n\nIn this example, the health check will be performed every 5 minutes, with a timeout of 3 seconds. If the curl command fails (i.e., the web server is not responding), the container will be considered unhealthy.\n\nYou can also use the `CMD` directive to specify the health check command:\n\n```\nHEALTHCHECK CMD curl -f http:\/\/localhost\/ || exit 1\n```\n\nIf you want to disable any existing health check inherited from the base image, you can use the `NONE` option:\n\n```\nHEALTHCHECK NONE\n```\n\nWhen a health check is configured, the status of the container will be displayed in the `docker ps` output. The status can be one of the following:\n\n- `starting`: The container is starting up and the health check has not been performed yet.\n- `healthy`: The container is healthy and the health check is passing.\n- `unhealthy`: The container is unhealthy and the health check is failing.\n\nYou can also use the `docker inspect` command to get more detailed information about the health status of a container:\n\n```\ndocker inspect --format '{{json .State.Health}}' \n```\n\nThis will return a JSON object with information about the health status, including the last check result, the number of failures, and the time of the last check.\n\nIn summary, the HEALTHCHECK directive is a powerful feature that allows you to monitor the health status of your containers and take appropriate actions based on the results. It helps ensure that your containers are functioning correctly and can help detect and resolve issues before they become critical.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile-healthcheck\/","og_locale":"fr_FR","og_type":"article","og_title":"Dockerfile HEALTHCHECK - Dockerpros","og_description":"The `HEALTHCHECK` instruction in a Dockerfile enables developers to define a command that tests the container's health. It helps ensure that services are running correctly, facilitating automated recovery and monitoring.","og_url":"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile-healthcheck\/","og_site_name":"Dockerpros","article_modified_time":"2024-07-23T12:23:24+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/","url":"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/","name":"Dockerfile HEALTHCHECK - Dockerpros\n\nThe HEALTHCHECK directive is a new feature introduced in Docker 1.12. It allows you to check the health status of a container. This directive is used to determine if a container is functioning correctly or not. It is particularly useful for detecting issues such as a web server that is stuck in an infinite loop and unable to handle new connections, even though the container is still running.\n\nThe HEALTHCHECK directive has the following syntax:\n\n```\nHEALTHCHECK [OPTIONS] CMD command\n```\n\nThe available options are:\n\n- `--interval=DURATION` (default: 30s): The time interval between health checks.\n- `--timeout=DURATION` (default: 30s): The maximum time to wait for the health check command to complete.\n- `--start-period=DURATION` (default: 0s): The initialization time during which the health check failures are ignored.\n- `--retries=N` (default: 3): The number of consecutive failures needed to consider the container as unhealthy.\n\nThe health check command can be any valid command that returns a zero exit code for success and a non-zero exit code for failure. For example, you can use a curl command to check if a web server is responding correctly:\n\n```\nHEALTHCHECK --interval=5m --timeout=3s \\\n  CMD curl -f http:\/\/localhost\/ || exit 1\n```\n\nIn this example, the health check will be performed every 5 minutes, with a timeout of 3 seconds. If the curl command fails (i.e., the web server is not responding), the container will be considered unhealthy.\n\nYou can also use the `CMD` directive to specify the health check command:\n\n```\nHEALTHCHECK CMD curl -f http:\/\/localhost\/ || exit 1\n```\n\nIf you want to disable any existing health check inherited from the base image, you can use the `NONE` option:\n\n```\nHEALTHCHECK NONE\n```\n\nWhen a health check is configured, the status of the container will be displayed in the `docker ps` output. The status can be one of the following:\n\n- `starting`: The container is starting up and the health check has not been performed yet.\n- `healthy`: The container is healthy and the health check is passing.\n- `unhealthy`: The container is unhealthy and the health check is failing.\n\nYou can also use the `docker inspect` command to get more detailed information about the health status of a container:\n\n```\ndocker inspect --format '{{json .State.Health}}' \n```\n\nThis will return a JSON object with information about the health status, including the last check result, the number of failures, and the time of the last check.\n\nIn summary, the HEALTHCHECK directive is a powerful feature that allows you to monitor the health status of your containers and take appropriate actions based on the results. It helps ensure that your containers are functioning correctly and can help detect and resolve issues before they become critical.","isPartOf":{"@id":"https:\/\/dockerpros.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#primaryimage"},"image":{"@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg","datePublished":"2024-07-23T12:20:35+00:00","dateModified":"2024-07-23T12:23:24+00:00","breadcrumb":{"@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#primaryimage","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg","width":800,"height":600,"caption":"dockerfile-healthcheck-2"},{"@type":"BreadcrumbList","@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-healthcheck\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dockerpros.com\/"},{"@type":"ListItem","position":2,"name":"Glossary","item":"https:\/\/dockerpros.com\/fr\/wiki\/"},{"@type":"ListItem","position":3,"name":"Dockerfile HEALTHCHECK"}]},{"@type":"WebSite","@id":"https:\/\/dockerpros.com\/#website","url":"https:\/\/dockerpros.com\/","name":"Dockerpros","description":"DockerPros \u2013 Votre centre de ressources Docker incontournable","publisher":{"@id":"https:\/\/dockerpros.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dockerpros.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/dockerpros.com\/#organization","name":"Dockerpros","url":"https:\/\/dockerpros.com\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","width":532,"height":114,"caption":"Dockerpros"},"image":{"@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary\/1320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":0,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary\/1320\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media\/1955"}],"wp:attachment":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media?parent=1320"}],"wp:term":[{"taxonomy":"glossary-cat","embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary-cat?post=1320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}