无法获取............哈希总和不匹配

时间:2019-09-27 09:21:41

标签: docker windows-10 apt-get

环境

  • 操作系统:Windows 10
  • Docker版本:2.1.0.3稳定的桌面社区
  • Docker Compose版本:1.24.1

Dockerfile

FROM postgres:11

COPY ./99fixbadproxy /etc/apt/apt.conf.d/99fixbadproxy

RUN apt-get -y update \
  && apt-get install -y \
    build-essential \
    python3-dev \
    python-gdal \
    libxml2 \
    libgeos-dev \
    libproj12 \
    postgresql-server-dev-11 \
    postgresql-11-postgis-2.5 \
    postgresql-11-postgis-scripts \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*

ADD ./init /docker-entrypoint-initdb.d/
第99章
Acquire::http::Pipeline-Depth 0;
Acquire::http::No-Cache true;
Acquire::BrokenProxy    true;

我执行的Docker命令

docker-compose build db

实际结果

Building db
Step 1/4 : FROM postgres:11
 ---> e2d75d1c1264
Step 2/4 : COPY ./99fixbadproxy /etc/apt/apt.conf.d/99fixbadproxy
 ---> Using cache
 ---> 5448c38eae1c
Step 3/4 : RUN apt-get -y update   && apt-get install -y     build-essential     python3-dev     python-gdal     libxml2     libgeos-dev     libproj12     postgresql-server-dev-11     postgresql-11-postgis-2.5     postgresql-11-postgis-scripts   && apt-get clean   && rm -rf /var/lib/apt/lists/*
 ---> Running in d930ce46b46e
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://apt.postgresql.org/pub/repos/apt stretch-pgdg InRelease [51.4 kB]
Get:3 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:4 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:5 http://deb.debian.org/debian stretch Release [118 kB]
Get:6 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages [184 kB]
Get:7 http://deb.debian.org/debian stretch-updates/main amd64 Packages [27.4 kB]
Get:8 http://deb.debian.org/debian stretch Release.gpg [2,365 B]
Get:9 http://deb.debian.org/debian stretch/main amd64 Packages [7,086 kB]
Get:10 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [497 kB]
Err:10 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
  Hash Sum mismatch
  Hashes of expected file:
   - Filesize:497208 [weak]
   - SHA256:2c51a7b9197719053220fc1d4c38453a48582d0190953481c0cd9620b8844a00
   - SHA1:6599fb50a02b4f3abe280b0bbfd42ba6227ae7d4 [weak]
   - MD5Sum:23a00a02efd96accdf62f7e6d27ee44b [weak]
  Hashes of received file:
   - SHA256:e8bb756eb3dae9f84b1ff2623bc3ff058e02775f60082cf1583ef789214a4a53
   - SHA1:b8fa8ff140603cb7b64f8f214957f35d1f85b987 [weak]
   - MD5Sum:fbb52af7168bde493aa4d9e6b65c6e34 [weak]
   - Filesize:497208 [weak]
  Last modification reported: Wed, 25 Sep 2019 06:37:02 +0000
  Release file created at: Thu, 26 Sep 2019 04:11:51 +0000
Fetched 8,151 kB in 7s (1,106 kB/s)
Reading package lists...
E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/by-hash/SHA256/2c51a7b9197719053220fc1d4c38453a48582d0190953481c0cd9620b8844a00  Hash Sum mismatch
   Hashes of expected file:
    - Filesize:497208 [weak]
    - SHA256:2c51a7b9197719053220fc1d4c38453a48582d0190953481c0cd9620b8844a00
    - SHA1:6599fb50a02b4f3abe280b0bbfd42ba6227ae7d4 [weak]
    - MD5Sum:23a00a02efd96accdf62f7e6d27ee44b [weak]
   Hashes of received file:
    - SHA256:e8bb756eb3dae9f84b1ff2623bc3ff058e02775f60082cf1583ef789214a4a53
    - SHA1:b8fa8ff140603cb7b64f8f214957f35d1f85b987 [weak]
    - MD5Sum:fbb52af7168bde493aa4d9e6b65c6e34 [weak]
    - Filesize:497208 [weak]
   Last modification reported: Wed, 25 Sep 2019 06:37:02 +0000
   Release file created at: Thu, 26 Sep 2019 04:11:51 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: Service 'db' failed to build: The command '/bin/sh -c apt-get -y update   && apt-get install -y     build-essential     python3-dev     python-gdal     libxml2     libgeos-dev     libproj12     postgresql-server-dev-11     postgresql-11-postgis-2.5     postgresql-11-postgis-scripts   
&& apt-get clean   && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

预期结果

Successfully built

我已经在Ubuntu,Debian和Arch Linux上测试过,该图像在任何Linux发行版中都可以正常工作。而且我什至没有包括步骤2。

我根据以下链接添加了步骤2,但不幸的是,它对我不起作用。 https://github.com/jenkinsci/docker/issues/543

docker version

的输出

客户端:Docker Engine-社区  版本:19.03.2  API版本:1.40  Go版本:go1.12.8  Git提交:6a30dfc  建造时间:2019年8月29日星期四05:26:49  操作系统/ Arch:Windows / amd64  实验性的:错误

服务器:Docker Engine-社区  发动机:   版本:19.03.2   API版本:1.40(最低版本1.12)   Go版本:go1.12.8   Git提交:6a30dfc   建造时间:2019年8月29日星期四05:32:21   操作系统/ Arch:linux / amd64   实验性:错误  装箱:   版本:v1.2.6   GitCommit:894b81a4b802e4eb2a91d1ce216b8817763c29fb  runc:   版本:1.0.0-rc8   GitCommit:425e105d5a03fabd737a126ad93d62a9eeede87f  码头工人初始化:   版本:0.18.0   GitCommit:fec3683

其他相关信息

  • 我尝试了自动和固定DNS服务器设置。
  • 我尝试在tcp上公开守护程序,而未选中和未选中TLS,认为可能是网络问题。
  • 我的代理被禁用。
  • 我尝试了其他基于debian的映像,并添加了apt-get更新行。但是,似乎在任何地方都无法使用。

3 个答案:

答案 0 :(得分:0)

将您的RUN更改为此:

RUN rm -rf /var/lib/apt/lists/partial && apt-get update -o Acquire::CompressionTypes::Order::=gz \
  && apt-get install -y \
    build-essential \
    python3-dev \
    python-gdal \
    libxml2 \
    libgeos-dev \
    libproj12 \
    postgresql-server-dev-11 \
    postgresql-11-postgis-2.5 \
    postgresql-11-postgis-scripts

在我发现这个answer之前,这件事在我身上发生了很多。它解决了我的构建中的问题。

答案 1 :(得分:0)

对于上述问题,我所做的只是更新新安装的Windows并重新启动计算机。然后,当我再次运行相同的Dockerfile时。

Wolla!有效。不知道事情怎么突然好起来。我中间什么都没改变。因此,任何人都可以解释为什么会发生这种情况。

答案 2 :(得分:0)

请按照以下步骤操作:

sudo rm -rf /var/lib/apt/lists/*
sudo apt-get update -o Acquire::CompressionTypes::Order::=gz
sudo apt-get update && sudo apt-get upgrade

希望这会有所帮助。