我的 Docker 映像构建不断失败,并出现以下两个错误之一:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/main/binary-amd64/by-hash/SHA256/ff7fd80e902a1acfba06e7b513711da31abe915d95b3ba39ce198e02efd209e5 Hash Sum mismatch
Hashes of expected file:
- Filesize:1343916 [weak]
- SHA256:ff7fd80e902a1acfba06e7b513711da31abe915d95b3ba39ce198e02efd209e5
- SHA1:edd753d5bd860c126016feca4e898a736999915b [weak]
- MD5Sum:9f666ceefac581815e5f3add8b30d3b9 [weak]
Hashes of received file:
- SHA256:e243776bf91c4d182410fe03e2b925c9fcfead68718b4caa09d20e8e46cf7c95
- SHA1:d7625072bd6ad2f0f5c9af714088954624914361 [weak]
- MD5Sum:14d1513c9ae5124fd53e092c82c408f8 [weak]
- Filesize:1343916 [weak]
Last modification reported: Thu, 26 Apr 2018 17:43:25 +0000
Release file created at: Thu, 26 Apr 2018 23:37:48 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.
如果我不断尝试反复构建图像,大概有 50% 的时间我会失败,但它会因以下错误而终止:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/b/boost1.65.1/libboost-wave1.65-dev_1.65.1+dfsg-0ubuntu5_amd64.deb 403 Forbidden [IP: 91.189.88.24 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
这是怎么回事?如何修复这些问题并让我的 docker 镜像构建时apt-get
不出现错误?如果我使用 ubuntu:16.04 作为基础镜像(而不是 ubuntu:18.04),就不会出现这些问题。
% docker build --network=host -t myimage:v18.04
FROM ubuntu:18.04
# Configure environment
ENV DEBIAN_FRONTEND=noninteractive \
TZ=America/New_York \
HOME=/root
# Install packages
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install \
automake \
autoconf \
libtool \
make \
curl \
gcc-8 \
g++-8 \
git \
gperf \
libboost-all-dev \
libevent-dev \
libhiredis-dev \
libssl-dev \
libtokyocabinet-dev \
tcsh \
python3-sphinx \
uuid-dev \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# And then other stuff.... But the Docker build never even gets past the previous RUN far.