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

首次使用Podman构建镜像失败,寻求解决方案

Podman拉取镜像DNS解析失败的解决办法

问题说明

执行Podman构建命令时出现lookup registry-1.docker.io: Temporary failure in name resolution错误,核心原因是Podman运行的虚拟机无法正常解析Docker Hub的域名。

你执行的命令:

podman machine init
podman machine start
podman build -t myimage .

Dockerfile开头:

FROM python:3.8-buster AS build

完整报错信息:

[1/2] STEP 1/11: FROM python:3.8-buster AS build
Resolved "python" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/python:3.8-buster...
Error: error creating build container: initializing source docker://python:3.8-buster: pinging 
container registry registry-1.docker.io: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io: Temporary failure in name resolution

解决步骤

1. 验证虚拟机网络连通性

先确认Podman虚拟机能否访问Docker Hub:

podman machine ssh ping -c 3 registry-1.docker.io

如果ping不通,说明虚拟机DNS配置异常,继续以下操作。

2. 修改Podman Machine的DNS设置

停止虚拟机,配置公共DNS(比如Google的8.8.8.8或Cloudflare的1.1.1.1):

podman machine stop
podman machine set --dns 8.8.8.8
podman machine start

3. 确认配置并重新构建

检查虚拟机的DNS配置是否生效:

podman machine ssh cat /etc/resolv.conf

确认输出中包含你设置的DNS地址后,重新执行构建命令:

podman build -t myimage .

4. 备选方案:直接使用完整镜像地址

若上述方法无效,可在Dockerfile中指定完整镜像路径,跳过短名称解析环节:

FROM docker.io/library/python:3.8-buster AS build

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 23:15:43