【问题标题】:How to fix 'Hash Sum Mismatch' in Docker on mac如何在 Mac 上修复 Docker 中的“哈希和不匹配”
【发布时间】:2021-05-28 02:52:03
【问题描述】:

我使用的是 macOS 11.4 和 Docker 3.3.3。我的 docker 文件看起来像

FROM python:3.8.10-slim-buster

RUN apt-get update && apt-get install --no-install-recommends -y \
    # dependencies for building Python packages
    build-essential \
    # psycopg2 dependencies
    libpq-dev

我已经尝试通过Python 使用不同标签的 Docker 映像,并尝试使用 --no-cache 命令创建映像,但是每次我尝试构建映像时,都会收到错误 Hash Sum mismatch

这是我的日志:

    [+] Building 5.8s (5/5) FINISHED                                                                                                                                                                          
 => [internal] load build definition from Dockerfile                                                                                                                                                 0.0s
 => => transferring dockerfile: 247B                                                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                                    0.0s
 => => transferring context: 34B                                                                                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/python:3.8.10-slim-buster                                                                                                                         2.6s
 => CACHED [1/2] FROM docker.io/library/python:3.8.10-slim-buster@sha256:c9dc8cd1171771e7f0def12be61d7bb340480e73b4e78acf3464ed0c3347dabd                                                            0.0s
 => ERROR [2/2] RUN apt-get update && apt-get install --no-install-recommends -y   build-essential   libpq-dev                                                                                       3.1s
------                                                                                                                                                                                                    
 > [2/2] RUN apt-get update && apt-get install --no-install-recommends -y   build-essential   libpq-dev:                                                                                                  
#5 0.751 Get:1 http://deb.debian.org/debian buster InRelease [121 kB]                                                                                                                                     
#5 0.751 Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]                                                                                                              
#5 0.967 Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]                                                                                                                            
#5 1.155 Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]                                                                                                                          
#5 1.204 Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [290 kB]
#5 2.833 Err:4 http://deb.debian.org/debian buster/main amd64 Packages
#5 2.833   Hash Sum mismatch
#5 2.833   Hashes of expected file:
#5 2.833    - Filesize:7906864 [weak]
#5 2.833    - SHA256:935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda
#5 2.833    - MD5Sum:ba791e511a2a4b6523ac06f404e32f42 [weak]
#5 2.833   Hashes of received file:
#5 2.833    - SHA256:3dbff74a7005b0214ed17ad72a4724cb91919d8d0221b5297f98f6153606bcaa
#5 2.833    - MD5Sum:f24d4da07e9d1e5bccd9d324cb36dd20 [weak]
#5 2.833    - Filesize:7906864 [weak]
#5 2.833   Last modification reported: Sat, 27 Mar 2021 09:33:56 +0000
#5 2.833   Release file created at: Sat, 27 Mar 2021 09:55:13 +0000
#5 3.000 Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [10.9 kB]
#5 3.020 Fetched 8447 kB in 3s (3163 kB/s)
#5 3.020 Reading package lists...
#5 3.053 E: Failed to fetch http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda  Hash Sum mismatch
#5 3.053    Hashes of expected file:
#5 3.053     - Filesize:7906864 [weak]
#5 3.053     - SHA256:935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda
#5 3.053     - MD5Sum:ba791e511a2a4b6523ac06f404e32f42 [weak]
#5 3.053    Hashes of received file:
#5 3.053     - SHA256:3dbff74a7005b0214ed17ad72a4724cb91919d8d0221b5297f98f6153606bcaa
#5 3.053     - MD5Sum:f24d4da07e9d1e5bccd9d324cb36dd20 [weak]
#5 3.053     - Filesize:7906864 [weak]
#5 3.053    Last modification reported: Sat, 27 Mar 2021 09:33:56 +0000
#5 3.053    Release file created at: Sat, 27 Mar 2021 09:55:13 +0000
#5 3.053 E: Some index files failed to download. They have been ignored, or old ones used instead.
------
executor failed running [/bin/sh -c apt-get update && apt-get install --no-install-recommends -y   build-essential   libpq-dev]: exit code: 100

非常感谢任何形式的帮助。 提前致谢。

【问题讨论】:

  • 我在 ubuntu:16.04 映像上运行时遇到了同样的问题...我什至尝试更改镜像服务器...没有用。本来这个问题不存在的……一定有什么改变了。我能够在较早的构建标记中运行 apt-get update,但在我更新 apt-get 存储库后再次失败......我的 dockerfile 的一部分。

标签: docker ubuntu dockerfile apt-get docker-for-mac


【解决方案1】:

This 回答最终解决了我的问题。即将下面的代码放在RUN apt-get update

之前
RUN rm -rf /var/lib/apt/lists/*
RUN apt-get clean
RUN apt-get update -o Acquire::CompressionTypes::Order::=gz

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-13
    • 2013-08-20
    • 2021-04-23
    • 2018-11-30
    • 1970-01-01
    • 1970-01-01
    • 2011-09-12
    相关资源
    最近更新 更多