{"version":"1.0","provider_name":"Profesionales de Docker","provider_url":"https:\/\/dockerpros.com\/es","title":"Dockerfile HEALTHCHECK - Dockerpros","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"BVDaIYZElB\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/dockerfile-healthcheck\/\">HEALTHCHECK\n\nLa instrucci\u00f3n HEALTHCHECK le dice a Docker c\u00f3mo probar un contenedor para verificar si a\u00fan est\u00e1 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\u00eda se est\u00e1 ejecutando.\n\nCuando se especifica un HEALTHCHECK, adem\u00e1s de su estado normal, el contenedor tiene un estado de salud. Este estado se determina inicialmente como saludable despu\u00e9s 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\u00e9n establece el estado del contenedor en no saludable.\n\nLa instrucci\u00f3n HEALTHCHECK tiene dos formas:\n\nHEALTHCHECK [OPCIONES] CMD comando (verifica la salud del contenedor ejecutando un comando dentro del mismo)\nHEALTHCHECK NONE (desactiva cualquier HEALTHCHECK heredado de la imagen base)\n\nLa forma HEALTHCHECK [OPCIONES] CMD incluye las mismas opciones que la forma CMD. Las opciones que acepta son:\n\n--interval=DURACI\u00d3N (por defecto: 30s)\n--timeout=DURACI\u00d3N (por defecto: 30s)\n--start-period=DURACI\u00d3N (por defecto: 0s)\n--retries=N\u00daMERO (por defecto: 3)\n\nLa comprobaci\u00f3n de salud se ejecuta en el intervalo especificado por el intervalo. Si una sola ejecuci\u00f3n de la comprobaci\u00f3n dura m\u00e1s que el tiempo de espera, la comprobaci\u00f3n se considera fallida.\n\nSe permiten un m\u00e1ximo de retries intentos de comprobaci\u00f3n antes de considerar el contenedor no saludable. Si una comprobaci\u00f3n de salud tiene \u00e9xito, el contenedor se considera saludable. Despu\u00e9s de un n\u00famero configurable de comprobaciones consecutivas fallidas, se considera no saludable.\n\nEl per\u00edodo de inicio se trata de un per\u00edodo 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\u00f3n de estado falla durante el per\u00edodo de inicio. Sin embargo, si una comprobaci\u00f3n de estado tiene \u00e9xito durante el per\u00edodo de inicio, el contenedor se considera saludable y conserva ese estado.\n\nUn HEALTHCHECK debe ser un CMD para comprobar la salud del contenedor. Hay cuatro tipos de estados de salida del comando HEALTHCHECK:\n\n0: \u00e9xito: el contenedor est\u00e1 sano y listo para su uso\n1: insalubre: el contenedor no est\u00e1 funcionando correctamente\n2: reservado: no utilice este c\u00f3digo de salida\n\nPor ejemplo, para comprobar cada cinco minutos o menos que el servidor web puede atender la p\u00e1gina de inicio de su sitio web con el tiempo de espera de tres segundos:\n\nHEALTHCHECK --interval=5m --timeout=3s \\\n  CMD curl -f http:\/\/localhost\/ || exit 1\n\nEl estado de salud del contenedor se puede consultar con docker ps. Tambi\u00e9n se puede consultar con el comando docker inspect.\n\nCuando 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.<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/dockerpros.com\/es\/wiki\/dockerfile-healthcheck\/embed\/#?secret=BVDaIYZElB\" width=\"600\" height=\"338\" title=\"\u00abDockerfile HEALTHCHECK\u00bb \u2014 Dockerpros\" data-secret=\"BVDaIYZElB\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe><script>\n\/**\n * WordPress inline HTML embed\n *\n * @since 4.4.0\n * @output wp-includes\/js\/wp-embed.js\n *\n * Single line comments should not be used since they will break\n * the script when inlined in get_post_embed_html(), specifically\n * when the comments are not stripped out due to SCRIPT_DEBUG\n * being turned on.\n *\/\n(function ( window, document ) {\n\t'use strict';\n\n\t\/* Abort for ancient browsers. *\/\n\tif ( ! document.querySelector || ! window.addEventListener || typeof URL === 'undefined' ) {\n\t\treturn;\n\t}\n\n\t\/** @namespace wp *\/\n\twindow.wp = window.wp || {};\n\n\t\/* Abort if script was already executed. *\/\n\tif ( !! window.wp.receiveEmbedMessage ) {\n\t\treturn;\n\t}\n\n\t\/**\n\t * Receive embed message.\n\t *\n\t * @param {MessageEvent} e\n\t *\/\n\twindow.wp.receiveEmbedMessage = function( e ) {\n\t\tvar data = e.data;\n\n\t\t\/* Verify shape of message. *\/\n\t\tif (\n\t\t\t! ( data || data.secret || data.message || data.value ) ||\n\t\t\t\/[^a-zA-Z0-9]\/.test( data.secret )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar iframes = document.querySelectorAll( 'iframe[data-secret=\"' + data.secret + '\"]' ),\n\t\t\tblockquotes = document.querySelectorAll( 'blockquote[data-secret=\"' + data.secret + '\"]' ),\n\t\t\tallowedProtocols = new RegExp( '^https?:$', 'i' ),\n\t\t\ti, source, height, sourceURL, targetURL;\n\n\t\tfor ( i = 0; i < blockquotes.length; i++ ) {\n\t\t\tblockquotes[ i ].style.display = 'none';\n\t\t}\n\n\t\tfor ( i = 0; i < iframes.length; i++ ) {\n\t\t\tsource = iframes[ i ];\n\n\t\t\tif ( e.source !== source.contentWindow ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tsource.removeAttribute( 'style' );\n\n\t\t\tif ( 'height' === data.message ) {\n\t\t\t\t\/* Resize the iframe on request. *\/\n\t\t\t\theight = parseInt( data.value, 10 );\n\t\t\t\tif ( height > 1000 ) {\n\t\t\t\t\theight = 1000;\n\t\t\t\t} else if ( ~~height < 200 ) {\n\t\t\t\t\theight = 200;\n\t\t\t\t}\n\n\t\t\t\tsource.height = height;\n\t\t\t} else if ( 'link' === data.message ) {\n\t\t\t\t\/* Link to a specific URL on request. *\/\n\t\t\t\tsourceURL = new URL( source.getAttribute( 'src' ) );\n\t\t\t\ttargetURL = new URL( data.value );\n\n\t\t\t\tif (\n\t\t\t\t\tallowedProtocols.test( targetURL.protocol ) &&\n\t\t\t\t\ttargetURL.host === sourceURL.host &&\n\t\t\t\t\tdocument.activeElement === source\n\t\t\t\t) {\n\t\t\t\t\twindow.top.location.href = data.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tfunction onLoad() {\n\t\tvar iframes = document.querySelectorAll( 'iframe.wp-embedded-content' ),\n\t\t\ti, source, secret;\n\n\t\tfor ( i = 0; i < iframes.length; i++ ) {\n\t\t\t\/** @var {IframeElement} *\/\n\t\t\tsource = iframes[ i ];\n\n\t\t\tsecret = source.getAttribute( 'data-secret' );\n\t\t\tif ( ! secret ) {\n\t\t\t\t\/* Add secret to iframe *\/\n\t\t\t\tsecret = Math.random().toString( 36 ).substring( 2, 12 );\n\t\t\t\tsource.src += '#?secret=' + secret;\n\t\t\t\tsource.setAttribute( 'data-secret', secret );\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Let post embed window know that the parent is ready for receiving the height message, in case the iframe\n\t\t\t * loaded before wp-embed.js was loaded. When the ready message is received by the post embed window, the\n\t\t\t * window will then (re-)send the height message right away.\n\t\t\t *\/\n\t\t\tsource.contentWindow.postMessage( {\n\t\t\t\tmessage: 'ready',\n\t\t\t\tsecret: secret\n\t\t\t}, '*' );\n\t\t}\n\t}\n\n\twindow.addEventListener( 'message', window.wp.receiveEmbedMessage, false );\n\tdocument.addEventListener( 'DOMContentLoaded', onLoad, false );\n})( window, document );\n\/\/# sourceURL=https:\/\/dockerpros.com\/wp-includes\/js\/wp-embed.js\n<\/script>","thumbnail_url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-healthcheck_1320.jpg","thumbnail_width":800,"thumbnail_height":600,"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."}