无法构build任何Dockerfile

我对我的问题尝试了不同的答案,但似乎没有任何工作。 当我试图build立任何docker文件时,我最终有相同的错误信息:

E: Unable to locate package htop INFO[0000] The command [/bin/sh -c apt-get install -y htop] returned a >non-zero code: 100 

这是Dockerfile:

 FROM debian:latest MAINTAINER <my_email> RUN apt-get update RUN apt-get install -y htop RUN apt-get clean 

我运行的命令是:

 sudo docker build -t demo . 

我也尝试不同的包,但都有相同的错误。

我得到的是:

 Sending build context to Docker daemon 3.649 MB Sending build context to Docker daemon Step 0 : FROM debian:latest ---> 9a61b6b1315e Step 1 : MAINTAINER anmol1696@gmail.com ---> Using cache ---> 9b4cd05e03fb Step 2 : RUN apt-get update ---> Using cache ---> 7f4979c6993d Step 3 : RUN apt-get install -y htop ---> Running in 7a2a26d155f5 Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package htop INFO[0000] The command [/bin/sh -c apt-get install -y htop] returned a non-zero code: 100 

请帮帮我。

这就是我在Ubuntu的docker镜像中得到apt-get update所做apt-get update

 Err http://archive.ubuntu.com trusty InRelease Err http://archive.ubuntu.com trusty-updates InRelease Err http://archive.ubuntu.com trusty-security InRelease Err http://archive.ubuntu.com trusty Release.gpg Could not resolve 'archive.ubuntu.com' Err http://archive.ubuntu.com trusty-updates Release.gpg Could not resolve 'archive.ubuntu.com' Err http://archive.ubuntu.com trusty-security Release.gpg Could not resolve 'archive.ubuntu.com' Reading package lists... Done W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/InRelease W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg Could not resolve 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Could not resolve 'archive.ubuntu.com' W: Some index files failed to download. They have been ignored, or old ones used instead. 

你给的上面的Dockerfile ,为我工作。 尝试再次获取中间层: docker build --no-cache=true -t <tag> .

使用的Dockerfile:

 FROM debian:latest MAINTAINER user@email.com RUN apt-get update && \ apt-get install -y htop && \ apt-get clean 

如怀疑,这是由于IPv6configuration。 看到这里 。

要解决这个问题:

  1. sudo nano / etc / default / docker
  2. 取消注释行DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
  3. 重启docker引擎service docker restart

尝试在您的Dockerfile中

FROM debian:latest MAINTAINER xx <xx@yy.com> RUN apt-get update && apt-get install -y htop && apt-get clean

我终于在PritamBarāl的帮助下得到了答案。 主要的问题是DNS服务器,因为我没有设置DNS