apt-get update 在以前工作的构建中失败并显示 404

apt-get update fails with 404 in a previously working build

我是 运行 Travis build,但在构建 mysql:5.7.27 docker 图像时失败了。 Dockerfile 运行 apt-get update,然后出现错误 W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages 404 Not Found

使用 curl 我可以看到它正在重定向,但是重定向到 URL 导致 404。有没有人见过这种行为并有补救措施?在 debian 进行更改之前,它基本上无法修复吗?

➜  ms git:(develop) curl --head http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages
HTTP/1.1 302 Found
Date: Tue, 26 Mar 2019 16:03:04 GMT
Server: Apache
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
Referrer-Policy: no-referrer
X-Xss-Protection: 1
Location: http://cdn-fastly.deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages
Content-Type: text/html; charset=iso-8859-1

➜  ms git:(develop) curl --head http://cdn-fastly.deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages
HTTP/1.1 404 Not Found
Server: Apache
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
Referrer-Policy: no-referrer
X-Xss-Protection: 1
Content-Type: text/html; charset=iso-8859-1
Via: 1.1 varnish
Content-Length: 316
Accept-Ranges: bytes
Date: Tue, 26 Mar 2019 16:03:17 GMT
Via: 1.1 varnish
Age: 45
Connection: keep-alive
X-Served-By: cache-ams21028-AMS, cache-cdg20741-CDG
X-Cache: HIT, HIT
X-Cache-Hits: 6, 2
X-Timer: S1553616198.734091,VS0,VE0

这是因为

as Wheezy and Jessie have been integrated into the archive.debian.org structure recently, we are now removing all of Wheezy and all non-LTS architectures of Jessie from the mirror network starting today.

(如您所见here

一个解决方案(根据 https://github.com/debuerreotype/docker-debian-artifacts/issues/66#issuecomment-476616579)是添加这一行:

RUN sed -i '/jessie-updates/d' /etc/apt/sources.list  # Now archived
在使用 debian:jessie 时调用 any apt-get update 之前

进入你的 Dockerfile。这将从 sources.list.

中删除 jessie-updates 存储库(现在导致 404)

因此,虽然以下内容不起作用:

FROM debian:jessie
RUN apt-get update
CMD /bin/sh

它的工作原理如下:

FROM debian:jessie
RUN sed -i '/jessie-updates/d' /etc/apt/sources.list  # Now archived
RUN apt-get update
CMD /bin/sh