I am trying build image php:8.1-fpm + nginx web server.
My Dockerfile:
# Используем официальный образ PHP-FPM
FROM php:8.1-fpm
RUN apt-get update && apt-get install -y nginx
COPY . /var/www/html/
COPY nginx.conf /etc/nginx/sites-available/default
# Устанавливаем Composer и зависимости проекта
RUN apt-get install -y unzip
&& curl -sS https://getcomposer.org/installer | php
&& php composer.phar install
RUN docker-php-ext-install pdo pdo_mysql
CMD service nginx start && php-fpm
During build I have errors, cant fetch debian packages:
17.12 E: Failed to fetch http://deb.debian.org/debian/pool/main/e/elfutils/libelf1_0.188-2.1_amd64.deb Connection failed [IP: 146.75.118.132 80]
17.12 E: Failed to fetch http://deb.debian.org/debian/pool/main/libb/libbpf/libbpf1_1.1.0-1_amd64.deb Connection failed [IP: 146.75.118.132 80]
17.12 E: Failed to fetch http://deb.debian.org/debian/pool/main/libb/libbsd/libbsd0_0.11.7-2_amd64.deb Connection failed [IP: 146.75.118.132 80]
17.12 E: Failed to fetch http://deb.debian.org/debian/pool/main/libm/libmnl/libmnl0_1.0.4-3_amd64.deb Connection failed [IP: 146.75.118.132 80]
############# many of the same errors
8.725 E: Failed to fetch http://deb.debian.org/debian/pool/main/u/unzip/unzip_6.0-28_amd64.deb Connection failed [IP: 151.101.246.132 80]
How did I try to fix it?
Changed php images, tried bullseye, newer version 8.2, another version 8.1.2
it didn’t work
Tried change host deb.debian.org to archive.debian.org
it didn’t work
Tried to delete docker cache
it didn’t work
How to fetch packages correctly?
So, after much trying, the solution has been found
You need to download from https, not http
incorrect http://deb.debian.org/debian/pool/main/u/unzip/unzip_6.0-28_amd64.deb
should be
https://deb.debian.org/debian/pool/main/u/unzip/unzip_6.0-28_amd64.deb
I changed manually host schema
RUN grep -rl 'http://deb.debian.org' /etc/apt/ | xargs sed -i 's|http://deb.debian.org|https://deb.debian.org|g'
so, correct dockerfile
FROM php:8.1-fpm
RUN grep -rl 'http://deb.debian.org' /etc/apt/ | xargs sed -i 's|http://deb.debian.org|https://deb.debian.org|g'
RUN apt-get update && apt-get install -y nginx
COPY . /var/www/html/
...........