ubuntu - UBUNTU - 无法生成任何Dockerfile

83 3

当我尝试构建任何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



请帮助我。

这就是我在apt-get update的Docker映像中做到的:

 

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.



时间: 原作者:

80 5

你给我的上面那个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



原作者:
117 2

怀疑,这是由于IPv6配置。请参见这里 。

要解决这个问题:

  • sudo nano /etc/default/docker
  • 取消注释行 DOCKER_OPTS= "--dns 8.8.8.8 --dns 8.8.4.4"
  • 重新启动Docker引擎service docker restart
原作者:
114 2

在Dockerfile中尝试使用它

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

原作者:
95 5

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

原作者:
...