在Docker下api-get“从服务器读取错误”


14

我在Bash中运行以下命令:

DEBIAN_FRONTEND=noninteractive apt-get update -qq \
  && apt-get install -y build-essential git libncurses5-dev openssl \
     libssl-dev  fop xsltproc unixodbc-dev curl

它运行,但在中间失败:

Get:96 http://security.debian.org/ jessie/updates/main linux-libc-dev amd64 3.16.7-ckt9-3~deb8u1 [991 kB]
Get:97 http://security.debian.org/ jessie/updates/main curl amd64 7.38.0-4+deb8u2 [200 kB]
Get:98 http://security.debian.org/ jessie/updates/main openjdk-7-jre amd64 7u79-2.5.5-1~deb8u1 [176 kB]
Get:99 http://http.debian.net/debian/ jessie/main libgtk2.0-0 amd64 2.24.25-3 [2301 kB]
Err http://http.debian.net/debian/ jessie/main dpkg-dev all 1.17.25
  Error reading from server. Remote end closed connection [IP: 176.9.184.93 80]
Get:100 http://http.debian.net/debian/ jessie/main libatk-wrapper-java all 0.30.5-1 [30.3 kB]
Get:101 http://http.debian.net/debian/ jessie/main libatk-wrapper-java-jni amd64 0.30.5-1 [24.8 kB]
Get:102 http://http.debian.net/debian/ jessie/main libatomic1 amd64 4.9.2-10 [8992 B]
Get:103 http://http.debian.net/debian/ jessie/main libavahi-glib1 amd64 0.6.31-5 [36.4 kB]

因此整个操作失败并显示错误

E: Failed to fetch http://http.debian.net/debian/pool/main/d/dpkg/dpkg-dev_1.17.25_all.deb  Error reading from server. Remote end closed connection [IP: 176.9.184.93 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

我将其作为Docker构建的一部分进行运行。我的Dockerfile读取

FROM debian:jessie
RUN DEBIAN_FRONTEND=noninteractive  \
    apt-get update -qq \
    && apt-get install -y \
       build-essential \
       git \
       libncurses5-dev \
       openssl \
       libssl-dev \
       fop \
       xsltproc \
       unixodbc-dev \
       curl

而我正在跑步 docker build -t my-base:latest .

apt-get命令有时会成功执行,而有时会失败而无需更改任何内容。在本地开发计算机上运行它似乎总是成功,但是在EC2计算机上运行它却经常(但并非总是!)失败。此外,apt-get updateapt-get install帮助之前似乎连续运行两次。不过,我对最后两句话完全不满意。

任何想法可能会发生什么?apt-get中是否可以缓存某个时间戳,然后期望它是最新的?

Answers:


22

这是您在Docker映像中更经常看到的一个问题,因为您正在访问的存储库经常更改,但是基本映像(及其缓存的元数据)却不会更改。

apt-get clean && apt-get update在安装软件包之前,请尝试运行。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.