过去两周,我的哈希值不匹配问题一直存在。起初我没怎么在意,但现在它们持续了这么久,肯定存在潜在问题。
我在常规机器上看到了它们,但在启动 Docker 容器时也看到了它们。我没想到在 Docker 容器中也会看到它们。我以为只是我的主机上有一些配置错误。为了解决这个问题,我尝试了各种排列组合
sudo rm -rf /var/lib/apt/lists/*
sudo apt update
sudo apt clean
根据多个主题的建议:
- https://stackoverflow.com/questions/47083839/hash-sum-mismatch-in-ubuntu-16-04-3
- 由于“哈希值不匹配”错误,无法下载软件包列表
还有其他想法吗?
输出
sudo rm -rf /var/lib/apt/lists/*
sudo apt update
是
Get:2 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease [21,3 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Get:4 http://archive.canonical.com/ubuntu bionic InRelease [10,2 kB]
Get:5 https://download.docker.com/linux/ubuntu bionic InRelease [64,4 kB]
Get:6 https://packages.microsoft.com/repos/vscode stable InRelease [3.182 B]
Get:7 http://archive.canonical.com/ubuntu bionic/partner i386 Packages [2.300 B]
Get:8 http://archive.canonical.com/ubuntu bionic/partner amd64 Packages [2.304 B]
Get:9 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88,7 kB]
Get:10 http://archive.canonical.com/ubuntu bionic/partner Translation-en [1.272 B]
Get:11 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main i386 Packages [15,8 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74,6 kB]
Get:13 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages [96,6 kB]
Get:14 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main amd64 Packages [18,8 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88,7 kB]
Get:16 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [4.696 B]
Get:17 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic/main Translation-en [5.372 B]
Get:18 https://download.docker.com/linux/ubuntu bionic/stable amd64 Contents (deb) [1.832 B]
Get:19 http://archive.ubuntu.com/ubuntu bionic/main i386 Packages [1.007 kB]
Get:20 https://typora.io/linux ./ InRelease [758 B]
Get:21 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1.019 kB]
Get:22 http://archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB]
Get:23 http://archive.ubuntu.com/ubuntu bionic/main amd64 DEP-11 Metadata [477 kB]
Get:1 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease [23,5 kB]
Get:24 https://typora.io/linux ./ Packages [9.872 B]
Get:25 http://archive.ubuntu.com/ubuntu bionic/main DEP-11 48x48 Icons [118 kB]
Get:26 http://archive.ubuntu.com/ubuntu bionic/main DEP-11 64x64 Icons [245 kB]
Get:27 http://archive.ubuntu.com/ubuntu bionic amd64 Contents (deb) [39,5 MB]
Ign:28 https://packagecloud.io/slacktechnologies/slack/debian jessie/main i386 Packages
Get:29 https://packagecloud.io/slacktechnologies/slack/debian jessie/main amd64 Packages [9.630 B]
Get:28 https://packagecloud.io/slacktechnologies/slack/debian jessie/main i386 Packages [4.991 B]
Get:30 http://archive.ubuntu.com/ubuntu bionic i386 Contents (deb) [38,8 MB]
Get:31 http://archive.ubuntu.com/ubuntu bionic/restricted i386 Packages [9.156 B]
Get:32 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9.184 B]
Get:33 http://archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3.584 B]
Get:34 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [527 kB]
Get:35 http://archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [453 kB]
Get:36 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [196 kB]
Get:37 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [278 kB]
Get:38 http://archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66,7 kB]
Get:39 http://archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [123 kB]
Err:39 http://archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons
Hash Sum mismatch
Hashes of expected file:
- Filesize:122730 [weak]
- SHA256:efd861307ea8f09f87224776e01985a6dbfbcf98ee8bb6c5989a07da4db16096
- SHA1:532fb3103b75340dee8e8817aeb536a8e3385e8b [weak]
- MD5Sum:8e9145351f55ece4ea3958858a2bf647 [weak]
Hashes of received file:
- SHA256:d03f0153972054426d71cddc4f9617d4cf4d856a85dcc5cbe395df50231f46e3
- SHA1:ce4661e73c9134be116d8c755afe7d5ce5135c69 [weak]
- MD5Sum:9ba8bd1b0b02ecd2f63b43f4f6be80ed [weak]
- Filesize:122730 [weak]
Last modification reported: Mon, 25 Feb 2019 05:59:58 +0000
Release file created at: Mon, 25 Feb 2019 10:44:06 +0000
Err:40 http://archive.ubuntu.com/ubuntu bionic-updates amd64 Contents (deb)
Get:41 http://archive.ubuntu.com/ubuntu bionic-updates i386 Contents (deb) [16,0 MB]
Get:42 http://archive.ubuntu.com/ubuntu bionic-updates/restricted i386 Packages [6.948 B]
Get:43 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [6.996 B]
Get:44 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [3.076 B]
Get:45 http://archive.ubuntu.com/ubuntu bionic-backports amd64 Contents (deb) [4.254 B]
Get:46 http://archive.ubuntu.com/ubuntu bionic-backports i386 Contents (deb) [4.252 B]
Get:47 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [270 kB]
Get:48 http://archive.ubuntu.com/ubuntu bionic-security/main i386 Packages [203 kB]
Get:49 http://archive.ubuntu.com/ubuntu bionic-security/main Translation-en [101 kB]
Get:50 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B]
Get:51 http://archive.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [29 B]
Get:52 http://archive.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [29 B]
Get:53 http://archive.ubuntu.com/ubuntu bionic-security i386 Contents (deb) [11,3 MB]
Get:54 http://archive.ubuntu.com/ubuntu bionic-security amd64 Contents (deb) [16,9 MB]
Fetched 129 MB in 56s (2.291 kB/s)
Reading package lists... Done
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/dep11/by-hash/SHA256/efd861307ea8f09f87224776e01985a6dbfbcf98ee8bb6c5989a07da4db16096 Hash Sum mismatch
Hashes of expected file:
- Filesize:122730 [weak]
- SHA256:efd861307ea8f09f87224776e01985a6dbfbcf98ee8bb6c5989a07da4db16096
- SHA1:532fb3103b75340dee8e8817aeb536a8e3385e8b [weak]
- MD5Sum:8e9145351f55ece4ea3958858a2bf647 [weak]
Hashes of received file:
- SHA256:d03f0153972054426d71cddc4f9617d4cf4d856a85dcc5cbe395df50231f46e3
- SHA1:ce4661e73c9134be116d8c755afe7d5ce5135c69 [weak]
- MD5Sum:9ba8bd1b0b02ecd2f63b43f4f6be80ed [weak]
- Filesize:122730 [weak]
Last modification reported: Mon, 25 Feb 2019 05:59:58 +0000
Release file created at: Mon, 25 Feb 2019 10:44:06 +0000
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/by-hash/SHA256/e086d4aa81310865d65bd04e5202e1f84816cace2c9976896b047ffbb5e8ac40
W: Some index files failed to download. They have been ignored, or old ones used instead.
编辑:
还尝试过:https://unix.stackexchange.com/a/425791/233543. 没有快乐。
编辑:
sudo wget -q -S http://archive.ubuntu.com/ubuntu/dists/bionic/Release -O/dev/null
返回
HTTP/1.1 200 OK
Date: Mon, 25 Feb 2019 12:26:39 GMT
Server: Apache/2.4.18 (Ubuntu)
Last-Modified: Thu, 26 Apr 2018 23:38:40 GMT
ETag: "3ae1c-56ac8e31ec000"
Content-Length: 241180
Cache-Control: max-age=0, proxy-revalidate
Expires: Mon, 25 Feb 2019 12:26:39 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
答案1
在绝望中,我尝试了这个问题的所有答案:
其中一个评分较低的答案竟然起了作用,即:
https://askubuntu.com/a/809808/622128
确实,在启动 Docker 容器时,我也需要使用这个技巧。从现在开始,我想我将需要以下形式的 Docker 容器
FROM ubuntu:18.04
RUN printf "Acquire::http::Pipeline-Depth 0;\nAcquire::http::No-Cache true;\nAcquire::BrokenProxy true;" > /etc/apt/apt.conf.d/99fixbadproxy
RUN apt-get update
...
如果没有这个解决方案,Docker 甚至无法构建容器。