【问题标题】:E: Unable to locate package wget in dockerE: 无法在 docker 中找到包 wget
【发布时间】:2021-05-21 09:26:55
【问题描述】:

我正在尝试构建以下 dockerfile

FROM php:8.0-apache
RUN apt-get update
# because apparently composer can shell out to unzip? Who knew...
RUN apt-get install wget unzip zip -y

但它失败并出现以下错误

[root@dev svc]# docker build -t wsb -f Dockerfile .
Sending build context to Docker daemon 17.62 MB
Step 1/11 : FROM php:8.0-apache
 ---> 97f22a92e1d1
Step 2/11 : RUN apt-get update
 ---> Using cache
 ---> ddba6cf13bac
Step 3/11 : RUN apt-get install wget unzip zip -y
 ---> Running in 6fb3e2f37401
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package wget
E: Unable to locate package unzip
E: Unable to locate package zip
The command '/bin/sh -c apt-get install wget unzip zip -y' returned a non-zero code: 100

sources.list 文件的现有内容

# deb http://snapshot.debian.org/archive/debian/20210511T000000Z buster main
deb http://deb.debian.org/debian buster main
# deb http://snapshot.debian.org/archive/debian-security/20210511T000000Z buster/updates main
deb http://security.debian.org/debian-security buster/updates main
# deb http://snapshot.debian.org/archive/debian/20210511T000000Z buster-updates main
deb http://deb.debian.org/debian buster-updates main

我不确定为什么它无法找到。我应该向 /etc/apt/sources.list 添加任何 URL 以使其正常工作吗?

编辑

Sending build context to Docker daemon 17.62 MB
Step 1/9 : FROM php:8.0-apache
 ---> 97f22a92e1d1
Step 2/9 : RUN apt-get update     && apt-get install wget unzip zip -y
 ---> Running in 374b1060dfb3

Err:1 http://security.debian.org/debian-security buster/updates InRelease
  Temporary failure resolving 'security.debian.org'
Err:2 http://deb.debian.org/debian buster InRelease
  Temporary failure resolving 'deb.debian.org'
Err:3 http://deb.debian.org/debian buster-updates InRelease
  Temporary failure resolving 'deb.debian.org'
Reading package lists...
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.

【问题讨论】:

  • 请分享更多细节。这与编程有什么关系?您尝试过什么来解决您的问题?

标签: docker debian apt


【解决方案1】:

您缓存了一个过时的更新,因此 apt 正在尝试从不再位于存储库中的版本安装这些软件包。这就是为什么Docker's best practices 提到不要将这些步骤分开:

FROM php:8.0-apache
RUN apt-get update \
 && apt-get install wget unzip zip -y

从您现在看到的第二个问题来看,您的容器中存在网络问题。有很多可能的原因,包括主机没有连接到网络,以及 docker 引擎启动后网络发生变化。您需要提供更多调试(您能否从主机访问这些节点,DNS 是否正常工作,网络上是否有代理或防火墙等)。

【讨论】:

  • 感谢您的回答,但它不起作用。我更新了 EDIT 部分下的输出。
猜你喜欢
  • 2018-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-08
  • 1970-01-01
  • 2021-09-01
  • 2021-08-09
  • 1970-01-01
相关资源
最近更新 更多