我正在尝试构建以下 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
Run Code Online (Sandbox Code Playgroud)
但失败并出现以下错误
[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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我不确定为什么找不到。我应该向 /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.
Run Code Online (Sandbox Code Playgroud)
BMi*_*tch 11
您已经缓存了过时的更新,因此 apt 尝试从存储库中不再存在的版本安装这些软件包。这就是为什么Docker 的最佳实践提到不要分开这些步骤:
FROM php:8.0-apache
RUN apt-get update \
&& apt-get install wget unzip zip -y
Run Code Online (Sandbox Code Playgroud)
从您现在看到的第二个问题来看,您的容器内存在网络问题。可能的原因有很多,包括主机未连接到网络、docker引擎启动后网络发生变化等。您需要提供更多的调试(您能否从主机访问这些节点、DNS 是否正常工作、网络上是否有代理或防火墙等)。
| 归档时间: |
|
| 查看次数: |
19484 次 |
| 最近记录: |