The problem
Recently, some of our build processes have reported errors:
docker run --rm php:5.5 apt-get update
# apt-get update
Ign http://security.debian.org jessie/updates InRelease
Ign http://httpredir.debian.org jessie InRelease
Ign http://security.debian.org jessie/updates Release.gpg
Ign http://httpredir.debian.org jessie-updates InRelease
Ign http://security.debian.org jessie/updates Release
Ign http://httpredir.debian.org jessie Release.gpg
Err http://security.debian.org jessie/updates/main amd64 Packages
Ign http://httpredir.debian.org jessie-updates Release.gpg
Err http://security.debian.org jessie/updates/main amd64 Packages
Ign http://httpredir.debian.org jessie Release
Err http://security.debian.org jessie/updates/main amd64 Packages
Err http://security.debian.org jessie/updates/main amd64 Packages
Ign http://httpredir.debian.org jessie-updates Release
Err http://security.debian.org jessie/updates/main amd64 Packages
404 Not Found [IP: 151.101.2.132 80]
Err http://httpredir.debian.org jessie/main amd64 Packages
404 Not Found
Err http://httpredir.debian.org jessie-updates/main amd64 Packages
404 Not Found
W: Failed to fetch http://security.debian.org/dists/jessie/updates/main/binary-amd64/Packages 404 Not Found [IP: 151.101.2.132 80]
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
Or with PHP 5.6:
docker run --rm php:5.6 apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Ign:2 http://security.debian.org/debian-security stretch/updates InRelease
Ign:3 http://deb.debian.org/debian stretch-updates InRelease
Ign:4 http://security.debian.org/debian-security stretch/updates Release
Ign:5 http://deb.debian.org/debian stretch Release
Ign:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:7 http://deb.debian.org/debian stretch-updates Release
Ign:8 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:8 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:8 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:8 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:8 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Err:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
404 Not Found [IP: 151.101.2.132 80]
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:8 http://security.debian.org/debian-security stretch/updates/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:9 http://deb.debian.org/debian stretch/main amd64 Packages
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://deb.debian.org/debian stretch-updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Err:9 http://deb.debian.org/debian stretch/main amd64 Packages
404 Not Found
Ign:10 http://deb.debian.org/debian stretch/main all Packages
Err:11 http://deb.debian.org/debian stretch-updates/main amd64 Packages
404 Not Found
Ign:12 http://deb.debian.org/debian stretch-updates/main all Packages
Reading package lists...
W: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file.
W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/Packages 404 Not Found [IP: 151.101.2.132 80]
E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages 404 Not Found
E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
In both cases, it is an image based on the Linux Debian distribution. The problem is caused by the fact that Debian has changed the availability of package repositories and binaries are no longer available at the address in the image.
Removal of Wheezy and Jessie (except LTS) from mirrors
Debian 9/stretch moved to archive.debian.org
The solution
Accesses to current package repositories must be replaced. The new usable address is:
http://archive.debian.org/debian
The easiest way to do this is to simply delete the original settings and add the new addresses to the /etc/apt/sources.list
file. E.g.:
rm /etc/apt/sources.list
echo "deb http://archive.debian.org/debian/ jessie main" >> /etc/apt/sources.list
echo "deb http://archive.debian.org/debian/ jessie-backports main" >> /etc/apt/sources.list
Attention! The code snippet above shows the code name of the version (jessie
). If you use a different version, you have to replace it, e.g. with the code name stretch
in the case of Debian 9.
For a Dockerfile, I recommend including the next step
RUN rm /etc/apt/sources.list \
&& export DISTRIBUTION_NAME=$(grep "VERSION=" /etc/os-release | sed 's/^.*(\(.*\)).*$/\1/') \
&& echo "deb http://archive.debian.org/debian/ ${DISTRIBUTION_NAME} main" >> /etc/apt/sources.list \
&& echo "deb http://archive.debian.org/debian/ ${DISTRIBUTION_NAME}-backports main" >> /etc/apt/sources.list
The above method was tested with both jessie
and stretch
versions.
Thus, the apt-get update command works again in the container.