构建镜像不能安装python
来源:3-6 镜像的构建和分享

Named1
2024-02-28
[root@localhost code]# docker image build -t hello .
[+] Building 25.9s (7/8) docker:default
=> [internal] load build definition from dockerfile 0.0s
=> => transferring dockerfile: 263B 0.0s
=> [internal] load metadata for docker.io/library/centos:latest 2.8s
=> [auth] library/centos:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [1/3] FROM docker.io/library/centos:latest@sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6 0.0s
=> ERROR [2/3] RUN yum update -y && yum install -y python39 python39-devel python39-pip && yum clean al 23.1s
=> [internal] load build context 0.0s
=> => transferring context: 89B 0.0s
[2/3] RUN yum update -y && yum install -y python39 python39-devel python39-pip && yum clean all:
22.96 CentOS Linux 8 - AppStream 1.8 B/s | 38 B 00:21
22.97 Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
dockerfile:2
1 | FROM centos:latest
2 | >>> RUN yum update -y &&
3 | >>> yum install -y python39 python39-devel python39-pip &&
4 | >>> yum clean all
5 | ADD hello.py /
ERROR: failed to solve: process “/bin/sh -c yum update -y && yum install -y python39 python39-devel python39-pip && yum clean all” did not complete successfully: exit code: 1
写回答
1回答
-
麦兜搞IT
2025-04-24
有可能是CentOS 8 的官方软件源已停止维护,默认的
yum
源可能已经失效,导致无法安装软件包012025-04-24