I sometimes wanted to build a Docker image under a proxy environment, so I made it possible to set proxy information in ARG.
FROM debian
#Specify when building in a proxy environment
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN apt-get update \
&& apt-get install -y ... \
&& rm -rf /var/lib/apt/lists/*
$ docker build --build-arg HTTP_PROXY=... --build-arg HTTPS_PROXY=... .
(Abbreviation)
Err:1 http://deb.debian.org/debian buster InRelease
Cannot initiate the connection to prod.debian.map.fastly.net:80 (2a04:4e42:1a::204). - connect (101: Network is unreachable) Could not connect to prod.debian.map.fastly.net:80 (151.101.108.204), connection timed out
Cannot initiate the connection to deb.debian.org:80 (2a04:4e42:1a::645). - connect (101: Network is unreachable) Could not connect to deb.debian.org:80 (151.101.110.133), connection timed out
What? I can't go through a proxy.
Here is the correct answer that I found after half a day worrying about why this did not work.
FROM debian
#Specify when building in a proxy environment
ARG http_proxy
ARG https_proxy
RUN apt-get update \
&& apt-get install -y ... \
&& rm -rf /var/lib/apt/lists/*
$ docker build --build-arg http_proxy=... --build-arg https_proxy=... .
The cause of the defeat is the belief that "environment variables are specified in uppercase letters" and "environment variables cannot be Case Sensitive".
Dear Sir, Be careful when using apt-get in a proxy environment.