{"version":"1.0","provider_name":"Profesionales de Docker","provider_url":"https:\/\/dockerpros.com\/es","title":"Docker Compose Build Arguments - Dockerpros","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"7tr3GaQxHc\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/docker-compose-build-arguments\/\">Docker Compose es una herramienta que permite definir y ejecutar aplicaciones multi-contenedor de Docker. Utiliza archivos YAML para configurar los servicios de la aplicaci\u00f3n. Cuando se construyen im\u00e1genes de Docker en Compose, a veces es necesario pasar argumentos de compilaci\u00f3n para personalizar el proceso de construcci\u00f3n. Estos argumentos se conocen como \"build arguments\" en Docker Compose.\n\nLos build arguments son variables que se pasan al proceso de construcci\u00f3n de una imagen de Docker. Se definen en el Dockerfile con la instrucci\u00f3n ARG y se pueden establecer en tiempo de compilaci\u00f3n. En Docker Compose, se pueden especificar estos argumentos en la secci\u00f3n build del servicio correspondiente.\n\nPara utilizar build arguments en Docker Compose, se puede utilizar la clave args en la secci\u00f3n build del servicio. Esta clave acepta una lista de argumentos, donde cada argumento se especifica como un par clave-valor. Por ejemplo:\n\n```yaml\nversion: '3'\nservices:\n  web:\n    build:\n      context: .\n      args:\n        - VAR1=value1\n        - VAR2=value2\n```\n\nEn este ejemplo, se est\u00e1n pasando dos build arguments, VAR1 y VAR2, con los valores value1 y value2 respectivamente. Estos argumentos estar\u00e1n disponibles durante la construcci\u00f3n de la imagen del servicio web.\n\nTambi\u00e9n es posible utilizar variables de entorno como valores para los build arguments. Para ello, se puede utilizar la sintaxis ${VAR_NAME} en el valor del argumento. Por ejemplo:\n\n```yaml\nversion: '3'\nservices:\n  web:\n    build:\n      context: .\n      args:\n        - VAR1=${VAR1_ENV}\n        - VAR2=${VAR2_ENV}\n```\n\nEn este caso, los valores de VAR1 y VAR2 se obtendr\u00e1n de las variables de entorno VAR1_ENV y VAR2_ENV respectivamente.\n\nEs importante tener en cuenta que los build arguments solo est\u00e1n disponibles durante la construcci\u00f3n de la imagen y no persisten en la imagen resultante. Si se necesitan variables de entorno en el contenedor en tiempo de ejecuci\u00f3n, se deben utilizar las instrucciones ENV en el Dockerfile o las variables de entorno en la configuraci\u00f3n del servicio en Docker Compose.\n\nAdem\u00e1s, es posible utilizar build arguments para controlar el comportamiento condicional en el Dockerfile. Por ejemplo, se puede utilizar un build argument para determinar qu\u00e9 versi\u00f3n de una dependencia instalar o qu\u00e9 archivos incluir en la imagen. Esto permite crear im\u00e1genes m\u00e1s flexibles y personalizables.\n\nEn resumen, los build arguments en Docker Compose son una forma poderosa de personalizar el proceso de construcci\u00f3n de im\u00e1genes de Docker. Permiten pasar variables en tiempo de compilaci\u00f3n y controlar el comportamiento del Dockerfile. Al utilizarlos de manera efectiva, se pueden crear im\u00e1genes m\u00e1s flexibles y adaptadas a las necesidades espec\u00edficas de la aplicaci\u00f3n.<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/dockerpros.com\/es\/wiki\/docker-compose-build-arguments\/embed\/#?secret=7tr3GaQxHc\" width=\"600\" height=\"338\" title=\"\u00abArgumentos de construcci\u00f3n de Docker Compose\u00bb \u2014 Dockerpros\" data-secret=\"7tr3GaQxHc\" 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\/docker-compose-build-arguments_1272.jpg","thumbnail_width":800,"thumbnail_height":600,"description":"Docker Compose build arguments allow users to pass variables at build time to customize Docker images. By defining ARG directives in Dockerfiles, developers can dynamically configure builds for different environments."}