无法将 Fedora >34 拉取给 Docker?

无法将 Fedora >34 拉取给 Docker?

我使用 Fedora 作为 Docker 的基础镜像。由于我对当前版本了解甚少,我决定切换到更高版本。然而,它总是失败,因为镜像显然存在问题。

这是Dockerfile:

FROM fedora:34
ENV DEBIAN_FRONTEND=noninteractive
RUN dnf update -y
RUN dnf install -y lightdm
#And so on

这有效。

改用FROM fedora:35以下方式可以得到:

docker build -t graphing:latest -f Dockerfile .
Sending build context to Docker daemon  514.6MB
Step 1/18 : FROM fedora:35
35: Pulling from library/fedora
054e3e802ba7: Pull complete 
Digest: sha256:f1e3a29da8990568c1da6a460cf9658ee7e9b409aa39c2aded67f7ac1dfe7e8a
Status: Downloaded newer image for fedora:35
 ---> b97d90f26110
Step 2/18 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Running in dbdd43c68d78
Removing intermediate container dbdd43c68d78
 ---> 216a73ff85a3
Step 3/18 : RUN dnf update -y
 ---> Running in 19df4d4775c9
Fedora 35 - x86_64                              0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'fedora':
  - Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-35&arch=x86_64 [getaddrinfo() thread failed to start]
Error: Failed to download metadata for repo 'fedora': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-35&arch=x86_64 [getaddrinfo() thread failed to start]
The command '/bin/sh -c dnf update -y' returned a non-zero code: 1

使用FROM fedora:36给我:

docker build -t graphing:latest -f Dockerfile .
Sending build context to Docker daemon  514.6MB
Step 1/18 : FROM fedora:36
36: Pulling from library/fedora
e1deda52ffad: Pull complete 
Digest: sha256:cbf627299e327f564233aac6b97030f9023ca41d3453c497be2f5e8f7762d185
Status: Downloaded newer image for fedora:36
 ---> 98ffdbffd207
Step 2/18 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Running in a670d11df939
Removing intermediate container a670d11df939
 ---> e0664f0626e7
Step 3/18 : RUN dnf update -y
 ---> Running in 9082965ff7ce
Fedora 36 - x86_64                              0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'fedora':
  - Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-36&arch=x86_64 [getaddrinfo() thread failed to start]
Error: Failed to download metadata for repo 'fedora': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-36&arch=x86_64 [getaddrinfo() thread failed to start]
The command '/bin/sh -c dnf update -y' returned a non-zero code: 1

这个错误并不罕见,但出现在裸​​机上。我没有对镜像进行任何自定义配置。搜索了一段时间后,我很少能找到类似 docker 的东西。

也许使用 fastmirror 可以解决这个问题,但是如何在 Dockerfile 中实现它呢?

编辑:

$ docker --version
Docker version 20.10.7, build 20.10.7-0ubuntu1~20.04.
$ docker-compose --version
docker-compose version 1.18.0, build 8dd22a9
$ runc --version
runc version 1.0.0~rc95-0ubuntu1~20.04.2
spec: 1.0.2-dev
go: go1.13.8
libseccomp: 2.5.1

相关内容