Docker构建apt-get更新无法使用403获取

时间:2017-06-23 16:09:05

标签: ubuntu docker dockerfile

我已经看过几个关于此的问题,但没有一个与我的问题相同。我有一台服务器在我们的数据中心运行Ubuntu 16.04,所以它在技术上是一个虚拟机。我已经安装了Docker,现在我正在尝试构建以下Dockerfile:

FROM ubuntu:16.04

RUN apt-get update

更新失败。我得到了一堆:

Ign:35 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse all Packages
Ign:36 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages
Ign:37 http://archive.ubuntu.com/ubuntu xenial-backports/main all Packages
Ign:38 http://archive.ubuntu.com/ubuntu xenial-backports/restricted amd64 Packages
Ign:39 http://archive.ubuntu.com/ubuntu xenial-backports/restricted all Packages
Ign:40 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages
Ign:41 http://archive.ubuntu.com/ubuntu xenial-backports/universe all Packages

然后:

E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/universe/source/Sources  403  Forbidden [IP: 91.189.91.26 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/universe/source/Sources  403  Forbidden [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/universe/source/Sources  403  Forbidden [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/main/binary-amd64/Packages  403  Forbidden [IP: 91.189.88.152 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

在我的服务器上运行sudo apt-get update(不在Docker镜像中)运行正常。

1 个答案:

答案 0 :(得分:1)

我点击了类似的内容:apt-get update'docker build'期间/etc/apt/apt.conf会失败'sudo apt-get update'

在主机中设置,RUN mkdir -p /etc/apt COPY apt.conf /etc/apt` RUN apt-get update && \ apt-get -y install` 在主机中运行。

我将其修复如下:

  

第1步:将/etc/apt/apt.conf复制到本地目录所在的位置   Dockerfile驻留(为docker构建上下文目录)。

     

第2步:将以下行添加到Dockerfile:

struct stuff
相关问题