我对我的问题尝试了不同的答案,但似乎没有任何效果。 当我尝试构建任何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
:
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.
答案 0 :(得分:1)
你给的上述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
答案 1 :(得分:1)
怀疑,这是由于IPv6配置。请参阅here。
解决问题:
/etc/default/docker
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
service docker restart
答案 2 :(得分:0)
在Dockerfile中尝试使用它
FROM debian:latest
MAINTAINER xx <xx@yy.com>
RUN apt-get update && apt-get install -y htop && apt-get clean
答案 3 :(得分:0)
我终于在PritamBarāl的帮助下得到了答案。 主要问题是dns服务器,因为我在大学服务器上没有设置DNS