<?xml version="1.0"?>
<oembed><version>1.0</version><provider_name>Profesionales de Docker</provider_name><provider_url>https://dockerpros.com/es</provider_url><title>Dockerfile HEALTHCHECK - Dockerpros</title><type>rich</type><width>600</width><height>338</height><html>&lt;blockquote class="wp-embedded-content" data-secret="8uBILP43Yd"&gt;&lt;a href="https://dockerpros.com/es/wiki/dockerfile-healthcheck/"&gt;HEALTHCHECK

La instrucci&#xF3;n HEALTHCHECK le dice a Docker c&#xF3;mo probar un contenedor para verificar si a&#xFA;n est&#xE1; funcionando. Esto puede detectar casos como un servidor web atascado en un bucle infinito y no puede manejar nuevas conexiones, incluso si el servidor del proceso todav&#xED;a se est&#xE1; ejecutando.

Cuando se especifica un HEALTHCHECK, adem&#xE1;s de su estado normal, el contenedor tiene un estado de salud. Este estado se determina inicialmente como saludable despu&#xE9;s de que se inicia el contenedor. Cada HEALTHCHECK que pasa sin errores lo mantiene saludable, mientras que cada HEALTHCHECK que falla lo hace pasar a un estado no saludable. El primer HEALTHCHECK fallido tambi&#xE9;n establece el estado del contenedor en no saludable.

La instrucci&#xF3;n HEALTHCHECK tiene dos formas:

HEALTHCHECK [OPCIONES] CMD comando (verifica la salud del contenedor ejecutando un comando dentro del mismo)
HEALTHCHECK NONE (desactiva cualquier HEALTHCHECK heredado de la imagen base)

La forma HEALTHCHECK [OPCIONES] CMD incluye las mismas opciones que la forma CMD. Las opciones que acepta son:

--interval=DURACI&#xD3;N (por defecto: 30s)
--timeout=DURACI&#xD3;N (por defecto: 30s)
--start-period=DURACI&#xD3;N (por defecto: 0s)
--retries=N&#xDA;MERO (por defecto: 3)

La comprobaci&#xF3;n de salud se ejecuta en el intervalo especificado por el intervalo. Si una sola ejecuci&#xF3;n de la comprobaci&#xF3;n dura m&#xE1;s que el tiempo de espera, la comprobaci&#xF3;n se considera fallida.

Se permiten un m&#xE1;ximo de retries intentos de comprobaci&#xF3;n antes de considerar el contenedor no saludable. Si una comprobaci&#xF3;n de salud tiene &#xE9;xito, el contenedor se considera saludable. Despu&#xE9;s de un n&#xFA;mero configurable de comprobaciones consecutivas fallidas, se considera no saludable.

El per&#xED;odo de inicio se trata de un per&#xED;odo de gracia para que el contenedor se inicialice y, posiblemente, arranque antes de que se realicen las comprobaciones de estado. El contenedor no se considera no saludable si una comprobaci&#xF3;n de estado falla durante el per&#xED;odo de inicio. Sin embargo, si una comprobaci&#xF3;n de estado tiene &#xE9;xito durante el per&#xED;odo de inicio, el contenedor se considera saludable y conserva ese estado.

Un HEALTHCHECK debe ser un CMD para comprobar la salud del contenedor. Hay cuatro tipos de estados de salida del comando HEALTHCHECK:

0: &#xE9;xito: el contenedor est&#xE1; sano y listo para su uso
1: insalubre: el contenedor no est&#xE1; funcionando correctamente
2: reservado: no utilice este c&#xF3;digo de salida

Por ejemplo, para comprobar cada cinco minutos o menos que el servidor web puede atender la p&#xE1;gina de inicio de su sitio web con el tiempo de espera de tres segundos:

HEALTHCHECK --interval=5m --timeout=3s \
  CMD curl -f http://localhost/ || exit 1

El estado de salud del contenedor se puede consultar con docker ps. Tambi&#xE9;n se puede consultar con el comando docker inspect.

Cuando se extrae la imagen de un registro, la historia de la imagen se aclara. Una persona que extrae la imagen no puede ver la HEALTHCHECK de la imagen.&lt;/a&gt;&lt;/blockquote&gt;&lt;iframe sandbox="allow-scripts" security="restricted" src="https://dockerpros.com/es/wiki/dockerfile-healthcheck/embed/#?secret=8uBILP43Yd" width="600" height="338" title="&#xAB;Dockerfile HEALTHCHECK&#xBB; &#x2014; Dockerpros" data-secret="8uBILP43Yd" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"&gt;&lt;/iframe&gt;&lt;script&gt;
/**
 * WordPress inline HTML embed
 *
 * @since 4.4.0
 * @output wp-includes/js/wp-embed.js
 *
 * Single line comments should not be used since they will break
 * the script when inlined in get_post_embed_html(), specifically
 * when the comments are not stripped out due to SCRIPT_DEBUG
 * being turned on.
 */
(function ( window, document ) {
	'use strict';

	/* Abort for ancient browsers. */
	if ( ! document.querySelector || ! window.addEventListener || typeof URL === 'undefined' ) {
		return;
	}

	/** @namespace wp */
	window.wp = window.wp || {};

	/* Abort if script was already executed. */
	if ( !! window.wp.receiveEmbedMessage ) {
		return;
	}

	/**
	 * Receive embed message.
	 *
	 * @param {MessageEvent} e
	 */
	window.wp.receiveEmbedMessage = function( e ) {
		var data = e.data;

		/* Verify shape of message. */
		if (
			! ( data || data.secret || data.message || data.value ) ||
			/[^a-zA-Z0-9]/.test( data.secret )
		) {
			return;
		}

		var iframes = document.querySelectorAll( 'iframe[data-secret="' + data.secret + '"]' ),
			blockquotes = document.querySelectorAll( 'blockquote[data-secret="' + data.secret + '"]' ),
			allowedProtocols = new RegExp( '^https?:$', 'i' ),
			i, source, height, sourceURL, targetURL;

		for ( i = 0; i &lt; blockquotes.length; i++ ) {
			blockquotes[ i ].style.display = 'none';
		}

		for ( i = 0; i &lt; iframes.length; i++ ) {
			source = iframes[ i ];

			if ( e.source !== source.contentWindow ) {
				continue;
			}

			source.removeAttribute( 'style' );

			if ( 'height' === data.message ) {
				/* Resize the iframe on request. */
				height = parseInt( data.value, 10 );
				if ( height &gt; 1000 ) {
					height = 1000;
				} else if ( ~~height &lt; 200 ) {
					height = 200;
				}

				source.height = height;
			} else if ( 'link' === data.message ) {
				/* Link to a specific URL on request. */
				sourceURL = new URL( source.getAttribute( 'src' ) );
				targetURL = new URL( data.value );

				if (
					allowedProtocols.test( targetURL.protocol ) &amp;&amp;
					targetURL.host === sourceURL.host &amp;&amp;
					document.activeElement === source
				) {
					window.top.location.href = data.value;
				}
			}
		}
	};

	function onLoad() {
		var iframes = document.querySelectorAll( 'iframe.wp-embedded-content' ),
			i, source, secret;

		for ( i = 0; i &lt; iframes.length; i++ ) {
			/** @var {IframeElement} */
			source = iframes[ i ];

			secret = source.getAttribute( 'data-secret' );
			if ( ! secret ) {
				/* Add secret to iframe */
				secret = Math.random().toString( 36 ).substring( 2, 12 );
				source.src += '#?secret=' + secret;
				source.setAttribute( 'data-secret', secret );
			}

			/*
			 * Let post embed window know that the parent is ready for receiving the height message, in case the iframe
			 * loaded before wp-embed.js was loaded. When the ready message is received by the post embed window, the
			 * window will then (re-)send the height message right away.
			 */
			source.contentWindow.postMessage( {
				message: 'ready',
				secret: secret
			}, '*' );
		}
	}

	window.addEventListener( 'message', window.wp.receiveEmbedMessage, false );
	document.addEventListener( 'DOMContentLoaded', onLoad, false );
})( window, document );
//# sourceURL=https://dockerpros.com/wp-includes/js/wp-embed.js
&lt;/script&gt;</html><thumbnail_url>https://dockerpros.com/wp-content/uploads/2024/07/dockerfile-healthcheck_1320.jpg</thumbnail_url><thumbnail_width>800</thumbnail_width><thumbnail_height>600</thumbnail_height><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.</description></oembed>
