Issue
I'm coming across a strange behavior while running CI/CD job on a private gitlab. This job was working fine for months and for me the error doesn't make sense.
Here is what is happening with context :
The job is doing a docker build, so it is executing Dockerfile commands, and here's is my file content :
FROM mcr.microsoft.com/dotnet/aspnet:6.0
ARG build_configuration=production
WORKDIR /app
EXPOSE 80
RUN cat /etc/os-release
RUN apt update
RUN apt install -y apache2
Looks simple, but what is not working anymore is simply the installation of apache2. Here are the logs of the job :
After this operation, 75.3 MB of additional disk space will be used.
#27 2.852 Get:1 http://deb.debian.org/debian bullseye/main amd64 perl-modules-5.32 all 5.32.1-4+deb11u2 [2823 kB]
#27 2.903 Get:2 http://deb.debian.org/debian bullseye/main amd64 libgdbm6 amd64 1.19-2 [64.9 kB]
#27 2.919 Get:3 http://deb.debian.org/debian bullseye/main amd64 libgdbm-compat4 amd64 1.19-2 [44.7 kB]
#27 3.866 Get:4 http://deb.debian.org/debian bullseye/main amd64 libperl5.32 amd64 5.32.1-4+deb11u2 [4106 kB]
#27 4.020 Get:5 http://deb.debian.org/debian bullseye/main amd64 perl amd64 5.32.1-4+deb11u2 [293 kB]
#27 4.050 Get:6 http://deb.debian.org/debian bullseye/main amd64 libapr1 amd64 1.7.0-6+deb11u2 [106 kB]
#27 4.078 Get:7 http://deb.debian.org/debian bullseye/main amd64 libexpat1 amd64 2.2.10-2+deb11u5 [98.2 kB]
#27 4.117 Get:8 http://deb.debian.org/debian bullseye/main amd64 libaprutil1 amd64 1.6.1-5+deb11u1 [92.3 kB]
#27 4.217 Get:9 http://deb.debian.org/debian bullseye/main amd64 libsqlite3-0 amd64 3.34.1-3 [797 kB]
#27 4.236 Get:10 http://deb.debian.org/debian bullseye/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-5+deb11u1 [19.0 kB]
#27 4.255 Get:11 http://deb.debian.org/debian bullseye/main amd64 libsasl2-modules-db amd64 2.1.27+dfsg-2.1+deb11u1 [69.1 kB]
#27 4.281 Get:12 http://deb.debian.org/debian bullseye/main amd64 libsasl2-2 amd64 2.1.27+dfsg-2.1+deb11u1 [106 kB]
#27 4.341 Get:13 http://deb.debian.org/debian bullseye/main amd64 libldap-2.4-2 amd64 2.4.57+dfsg-3+deb11u1 [232 kB]
#27 4.358 Get:14 http://deb.debian.org/debian bullseye/main amd64 libaprutil1-ldap amd64 1.6.1-5+deb11u1 [17.2 kB]
#27 4.400 Get:15 http://deb.debian.org/debian bullseye/main amd64 libbrotli1 amd64 1.0.9-2+b2 [279 kB]
#27 4.432 Get:16 http://deb.debian.org/debian bullseye/main amd64 libnghttp2-14 amd64 1.43.0-1 [77.1 kB]
#27 4.451 Get:17 http://deb.debian.org/debian bullseye/main amd64 libpsl5 amd64 0.21.0-1.2 [57.3 kB]
#27 4.470 Get:18 http://deb.debian.org/debian bullseye/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d.1-2+b2 [60.8 kB]
#27 4.509 Get:19 http://deb.debian.org/debian bullseye/main amd64 libssh2-1 amd64 1.9.0-2 [156 kB]
#27 4.559 Get:20 http://deb.debian.org/debian bullseye/main amd64 libcurl4 amd64 7.74.0-1.3+deb11u7 [346 kB]
#27 4.580 Get:21 http://deb.debian.org/debian bullseye/main amd64 libjansson4 amd64 2.13.1-1.1 [39.7 kB]
#27 4.604 Get:22 http://deb.debian.org/debian bullseye/main amd64 liblua5.3-0 amd64 5.3.3-1.1+b1 [120 kB]
#27 4.697 Get:23 http://deb.debian.org/debian bullseye/main amd64 libxml2 amd64 2.9.10+dfsg-6.7+deb11u4 [693 kB]
#27 5.393 Get:24 http://deb.debian.org/debian bullseye/main amd64 apache2-bin amd64 2.4.56-1~deb11u2 [1431 kB]
#27 65.43 Err:25 http://deb.debian.org/debian bullseye/main amd64 apache2-data all 2.4.56-1~deb11u2
#27 65.43 Connection failed [IP: 199.232.170.132 80]
#27 65.52 Get:26 http://deb.debian.org/debian bullseye/main amd64 apache2-utils amd64 2.4.56-1~deb11u2 [265 kB]
#27 65.54 Get:27 http://deb.debian.org/debian bullseye/main amd64 media-types all 4.0.0 [30.3 kB]
#27 65.57 Get:28 http://deb.debian.org/debian bullseye/main amd64 mailcap all 3.69 [31.7 kB]
#27 65.58 Get:29 http://deb.debian.org/debian bullseye/main amd64 mime-support all 3.66 [10.9 kB]
#27 65.61 Get:30 http://deb.debian.org/debian bullseye/main amd64 libncurses6 amd64 6.2+20201114-2+deb11u1 [102 kB]
#27 65.66 Get:31 http://deb.debian.org/debian bullseye/main amd64 libncursesw6 amd64 6.2+20201114-2+deb11u1 [132 kB]
#27 95.72 Get:32 http://deb.debian.org/debian bullseye/main amd64 libprocps8 amd64 2:3.3.17-5 [63.9 kB]
#27 95.93 Get:33 http://deb.debian.org/debian bullseye/main amd64 procps amd64 2:3.3.17-5 [502 kB]
#27 96.16 Get:34 http://deb.debian.org/debian bullseye/main amd64 apache2 amd64 2.4.56-1~deb11u2 [278 kB]
#27 96.19 Get:35 http://deb.debian.org/debian bullseye/main amd64 netbase all 6.3 [19.9 kB]
#27 96.24 Get:36 http://deb.debian.org/debian bullseye/main amd64 bzip2 amd64 1.0.8-4 [49.3 kB]
#27 96.30 Get:37 http://deb.debian.org/debian bullseye/main amd64 libmagic-mgc amd64 1:5.39-3 [273 kB]
#27 96.35 Get:38 http://deb.debian.org/debian bullseye/main amd64 libmagic1 amd64 1:5.39-3 [126 kB]
#27 96.37 Get:39 http://deb.debian.org/debian bullseye/main amd64 file amd64 1:5.39-3 [69.1 kB]
#27 126.5 Get:40 http://deb.debian.org/debian bullseye/main amd64 xz-utils amd64 5.2.5-2.1~deb11u1 [220 kB]
#27 126.5 Get:41 http://deb.debian.org/debian bullseye/main amd64 libgpm2 amd64 1.20.7-8 [35.6 kB]
#27 126.6 Get:42 http://deb.debian.org/debian bullseye/main amd64 libldap-common all 2.4.57+dfsg-3+deb11u1 [95.8 kB]
#27 126.6 Get:43 http://deb.debian.org/debian bullseye/main amd64 libsasl2-modules amd64 2.1.27+dfsg-2.1+deb11u1 [104 kB]
#27 126.7 Get:44 http://deb.debian.org/debian bullseye/main amd64 psmisc amd64 23.4-2 [198 kB]
#27 126.8 Get:45 http://deb.debian.org/debian bullseye/main amd64 publicsuffix all 20220811.1734-0+deb11u1 [127 kB]
#27 156.8 Get:46 http://deb.debian.org/debian bullseye/main amd64 ssl-cert all 1.1.0+nmu1 [21.0 kB]
#27 156.8 E: Failed to fetch http://deb.debian.org/debian/pool/main/a/apache2/apache2-data_2.4.56-1%7edeb11u2_all.deb Connection failed [IP: 199.232.170.132 80]
#27 156.8 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
As you can see the apache2-data package is not fetchable and it happens everytime I try to run the job.
I've tried several things in order to fix this problem, but none of them worked :
- docker build with --no-cache parameter
- apt update && apt install -y apache2 in one command line instead of two
- restarting the gitlab runner which execute this job
- switch gitlab runner used for this job
- add --fix-missing at the end of apt install -y apache2
I also tried a wget command within the gitlab runner in order to see if the package was reachable, and it was indeed.
I have other projects on this private gitlab which have quite the same Dockerfile, and the behavior is the same for those ones.
I've tried to build the same Dockerfile on my local machine and it worked, so I suppose it's an environment problem ?
If anyone came across a similar problem or has any idea.. thanks !
Solution
A bit late here but I needed to force HTTPS for apt in order to make it work:
# Put those lines before any `apt install ...` command
RUN sed -i 's/^deb http:/deb https:/g' /etc/apt/sources.list
RUN sed -i 's/^deb-src http:/deb-src https:/g' /etc/apt/sources.list
Answered By - CTR Answer Checked By - Willingham (WPSolving Volunteer)