为什么我在执行 apt-get 更新时看到 Failed to fetch 错误

Why do I see Failed to fetch error while dping apt-get update

我的 jenkins 作业中的 apt-get 更新失败,拉取 docker 集线器相关存储库时出现 Http 404 错误

12:38:54 + uname -a
12:38:54 Linux c612ce175fe3 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
12:28:18 W: Failed to fetch https://apt.dockerproject.org/repo/dists/ubuntu-trusty/main/binary-amd64/Packages  HttpError404
12:28:18 
12:28:18 W: Failed to fetch https://apt.dockerproject.org/repo/dists/ubuntu-trusty/main/binary-i386/Packages  HttpError404
12:28:18 

我在几个较旧的 Ubuntu 测试系统上遇到了同样的问题。在搜索 404 错误 https://apt.dockerproject.org/

的 URL 时终于找到了这个通知

Notice: Shutting down dockerproject.org APT and YUM repos 2020-03-31

Docker will be shutting down the deprecated APT and YUM repositories hosted at "dockerproject.org" and "dockerproject.com" on the 31st of March 2020.

We noticed that this project is referencing one of these repositories, and recommend updating to use the "download.docker.com" repository to prevent disruption.

More info: https://www.docker.com/blog/changes-dockerproject-org-apt-yum-repositories/

我的解决方法是编辑 /etc/apt/sources.list.d/docker.list 或 /etc/apt/sources.list 并注释掉旧行并添加新行。对于我的 raspberry pi,我使用 [arch=armhf] 而不是 [arch=amd64],希望这对您有所帮助。

sudo vi /etc/apt/sources.list.d/docker.list

进行此更改

#       deb https://apt.dockerproject.org/repo ubuntu-trusty main
deb [arch=amd64] https://download.docker.com/linux/ubuntu trusty stable

我遇到了同样的问题。 但是我在 docker.list 文件中做了以下更改。

sudo nano /etc/apt/sources.list.d/docker.list

并进行了以下更改。

# deb https://apt.dockerproject.org/repo ubuntu-trusty main

然后,

sudo apt-get update

它对我有用。 谢谢。