apt-get install apt-transport-https在Docker中失败

时间:2019-06-05 12:27:25

标签: docker ubuntu jenkins docker-compose

我有一个基于FROM jenkins/jenkins:2.179映像的Docker容器。 我RUN使用了许多安装dotnet core的命令:

FROM jenkins/jenkins:2.179

RUN apt-get update && \
    apt-get -y install sudo  && \
    sudo apt-get install apt-transport-https

一旦到达sudo apt-get install apt-transport-https,它就会失败并抱怨:

W: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease  Could not connect to prod.debian.map.fastly.net:80 (151.101.112.204). - connect (111: Connection refused) Could not connect to deb.debian.org:80 (5.153.231.4). - connect (111: Connection refused) [IP: 5.153.231.4 80]
W: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/InRelease  Could not connect to prod.debian.map.fastly.net:80 (151.101.112.204). - connect (111: Connection refused) Could not connect to security.debian.org:80 (217.196.149.233). - connect (111: Connection refused) [IP: 217.196.149.233 80]
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease  Unable to connect to deb.debian.org:http: [IP: 5.153.231.4 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

知道为什么会发生吗?

1 个答案:

答案 0 :(得分:1)

我无法复制此图像,因此容器的Internet连接可能有问题(可能是Marc建议的代理问题),或者在尝试构建映像时当前没有可用的资源。

关于另一个主题–当我尝试使用您的确切代码重现此代码时,我遇到了错误:

E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)

由于最终您可能还会遇到此问题,因此您不应该在Dockerfile中使用sudo。尝试这样的事情:

FROM jenkins/jenkins:2.179

USER root
RUN \
    whoami \ # This will print "root"...
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        apt-transport-https

USER jenkins
RUN whoami # ... and this will print "jenkins"