使用最新的 centos:8 docker.hub 映像,我无法运行 yum。所有 yum 命令均失败并显示错误消息Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
。
可以像这样重现:
$ docker pull centos:8
8: Pulling from library/centos
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Image is up to date for centos:8
docker.io/library/centos:8
$ docker run -it --init --cap-add=SYS_PTRACE --network=host centos:8 /bin/bash
[root@docker-desktop /]# yum clean all
Failed to set locale, defaulting to C.UTF-8
0 files removed
[root@docker-desktop /]# yum update
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream 988 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
我不确定这是否是特定于 docker 镜像的问题,还是更广泛的 centos:8 问题。我明白了类似问题关于这个问题,一年多前就建议修改/etc/yum/vars/releasever
或删除/var/cache/dnf
,但该releasever
文件不存在于此图像中,删除该dnf
缓存也没有帮助。
任何能够解决此问题的帮助都将不胜感激。