You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker构建Ubuntu22.04镜像时apt无法找到python3包问题排查

问题原因分析

你的Dockerfile

FROM ubuntu:22.04
RUN apt-get install -y python3

构建错误输出

Step 1/2 : FROM ubuntu:22.04
 ---> c6b84b685f35
Step 2/2 : RUN apt-get install -y python3
 ---> Running in d1f4eff8d024
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package python3

错误原因

ubuntu:22.04的官方基础镜像里,APT的软件包索引是镜像发布时的静态快照,不会自动同步最新的包源信息。当镜像存在时间较长时,这些索引会过时,导致APT无法定位到python3包的有效下载地址。

另外,虽然python3是Ubuntu 22.04的默认软件包之一,但精简版的基础镜像可能并未预装,而未更新索引的情况下,APT甚至无法确认该包是否存在于源中,从而抛出"Unable to locate package"错误。


内容的提问来源于stack exchange,提问作者spraff

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 19:48:21