我有人在我的机器上设置了 docker,到目前为止一切都运行顺利。我只是尝试修剪卷以释放一些空间。当我尝试重建图像时(如果我在这里没有使用正确的术语,请原谅我,因为我对此很陌生并且专注于数据分析部分),我遇到了以下错误。
=> [internal] load build definition from Dockerfile.python 0.0s
=> => transferring dockerfile: 1.70kB 0.0s
=> [internal] load metadata for docker.io/library/centos:latest 2.0s
=> [auth] library/centos:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CANCELED [internal] load build context 1.1s
=> => transferring context: 55.43MB 1.0s
=> CACHED [ 1/16] FROM docker.io/library/centos:latest@sha256:a2 0.0s
=> ERROR [ 2/16] RUN dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos -y && dnf distro-sync -y 1.1s
------
> [ 2/16] RUN dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos -y && dnf distro-sync -y:
0.949 CentOS Linux 8 - Extras 0.0 B/s | 0 B 00:00
0.949 Errors during downloading metadata for repository 'extras':
0.949 - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=extras&infra=container [Could not resolve host: mirrorlist.centos.org]
0.953 Error: Failed to download metadata for repo 'extras': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=extras&infra=container [Could not resolve host: mirrorlist.centos.org]
------
2 warnings found (use docker --debug to expand):
- SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "DESTINATION_KEY") (line 64)
- SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SOURCE_KEY") (line 62)
Dockerfile.python:3
--------------------
2 |
3 | >>> RUN dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos -y && \
4 | >>> dnf distro-sync -y
5 |
--------------------
ERROR: failed to solve: process "/bin/sh -c dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos -y && dnf distro-sync -y" did not complete successfully: exit code: 1
我相信是我的 docker 文件中的下面一行导致了错误。我怎样才能减轻这种情况?
RUN dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos -y && \
dnf distro-sync -y
Centos 7 自 2024 年 6 月下旬起就已停止使用。他们已禁用其存储库,这就是出现与
mirrorlist.centos.org
有关的错误的原因。以下是有关 Centos 7 EOL 的一些详细信息:https://community.centminmod.com/threads/centos-7-end-of-life-eol-june-30-2024.25589/
尝试在容器内使用这些命令来禁用镜像列表:
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*