gpt4 book ai didi

ubuntu - 无法构建任何 Dockerfile

转载 作者:行者123 更新时间:2023-12-02 21:28:02 24 4
gpt4 key购买 nike

我对我的问题尝试了不同的答案,但似乎没有任何效果。
每当我尝试构建任何 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在 ubuntu 的 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.

最佳答案

以上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

关于ubuntu - 无法构建任何 Dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31698963/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com