<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>docker compose &#8211; SMsoft &#8211; informatica e dintorni</title>
	<atom:link href="https://blog.smsoft.it/tag/docker-compose-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.smsoft.it</link>
	<description>consigli settimanali su MacOS, GNU/Linux ed Open Source</description>
	<lastBuildDate>Tue, 08 Sep 2026 11:14:15 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=64987</generator>
	<item>
		<title>Docker compose: come passare il proxy nel Dockerfile</title>
		<link>https://blog.smsoft.it/2026/05/19/docker-compose-come-passare-il-proxy-nel-dockerfile/</link>
					<comments>https://blog.smsoft.it/2026/05/19/docker-compose-come-passare-il-proxy-nel-dockerfile/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 19 May 2026 08:30:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[MacOS]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[docker compose]]></category>
		<category><![CDATA[Dockerfile]]></category>
		<guid isPermaLink="false">https://blog.smsoft.it/?p=7042</guid>

					<description><![CDATA[Per per utilizzare un proxy all&#8217;interno della procedura di build prevista nel Dockerfile impostato dal compose.yaml è necessario effettuare sia una modifica al compose.yaml che al Dockerfile. Nel mio esempio il proxy è attivo sulla macchina host, pertanto lo si può &#8220;puntare&#8221; con il nome host.docker.internal avendo l&#8217;accortezza di aggiungere, come vedremo in avanti, nel ... <a title="Docker compose: come passare il proxy nel Dockerfile" class="read-more" href="https://blog.smsoft.it/2026/05/19/docker-compose-come-passare-il-proxy-nel-dockerfile/" aria-label="Per saperne di più su Docker compose: come passare il proxy nel Dockerfile">Leggi tutto</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Per per utilizzare un proxy all&#8217;interno della procedura di build prevista nel <strong>Dockerfile</strong> impostato dal <strong>compose.yaml </strong>è necessario effettuare sia una modifica al compose.yaml che al Dockerfile. </p>



<p class="wp-block-paragraph">Nel mio esempio il proxy è attivo sulla macchina <strong>host</strong>, pertanto lo si può &#8220;puntare&#8221; con il nome <strong>host.docker.internal</strong> avendo l&#8217;accortezza di aggiungere, come vedremo in avanti, nel file <strong>compose.yaml</strong>:</p>



<pre class="wp-block-code"><code>      extra_hosts:
        - "host.docker.internal:host-gateway"</code></pre>



<p class="wp-block-paragraph">Ipotizziamo che il <strong>Dockerfile</strong> contenga qualcosa di questo tipo:</p>



<pre class="wp-block-code"><code># Stage 1: Dipendenze
FROM node:20-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app</code></pre>



<p class="wp-block-paragraph">dobbiamo aggiungere le necessarie variabili facendolo diventare:</p>



<pre class="wp-block-code"><code># Stage 1: Dipendenze
FROM node:20-alpine AS deps
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG NO_PROXY

ENV HTTP_PROXY=${HTTP_PROXY}
ENV HTTPS_PROXY=${HTTPS_PROXY}
ENV NO_PROXY=${NO_PROXY}
ENV http_proxy=${HTTP_PROXY}
ENV https_proxy=${HTTPS_PROXY}
ENV no_proxy=${NO_PROXY}

RUN apk add --no-cache libc6-compat
WORKDIR /app</code></pre>



<p class="wp-block-paragraph">Importante: Se l&#8217;applicativo cerca la variabile proxy in altro modo, ad esempio pip lanciato nel docker file, bisognerà dichiarare il proxy anche li in modo specifico, es:</p>



<pre class="wp-block-code"><code>COPY requirements.txt .
RUN python -m pip config --user set global.proxy $HTTP_PROXY
RUN pip install --no-cache-dir -r requirements.txt</code></pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">ora passiamo a modificare il <strong>compose.yaml</strong> che da:</p>



<pre class="wp-block-code"><code>services:
  app:
    image: gest:latest
    build:
      context: .
      dockerfile: Dockerfile
      args:
        BUILD_GIT_SHA: ${BUILD_GIT_SHA:-unknown}
        BUILD_DATE: ${BUILD_DATE:-unknown}
    container_name: app-club
    restart: unless-stopped</code></pre>



<p class="wp-block-paragraph">dovrà diventare:</p>



<pre class="wp-block-code"><code>services:
  app:
    image: gest:latest
    build:
      context: .
      dockerfile: Dockerfile
      args:
        BUILD_GIT_SHA: ${BUILD_GIT_SHA:-unknown}
        BUILD_DATE: ${BUILD_DATE:-unknown}
        HTTP_PROXY: http://host.docker.internal:8888
        HTTPS_PROXY: http://host.docker.internal:8888
        NO_PROXY: 127.0.0.1,localhost
      extra_hosts:
        - "host.docker.internal:host-gateway"
    container_name: app-club
    restart: unless-stopped
    extra_hosts:
      - "host.docker.internal:host-gateway"</code></pre>



<p class="wp-block-paragraph"><strong>Nota</strong>: il TAG <strong>extra_hosts</strong> è ripetuto due volte, perché uno viene passato come ARG e l&#8217;altro viene usato dalla machcina docker.</p>



<p class="wp-block-paragraph">enjoy!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.smsoft.it/2026/05/19/docker-compose-come-passare-il-proxy-nel-dockerfile/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
