Podman与WSL网络通信异常:镜像拉取超时/解析失败求助
Podman/Docker镜像拉取失败:网络连接与域名解析问题
问题现象
初始Podman拉取错误
PS C:\WINDOWS\system32> podman pull quay.io/podman/hello Trying to pull quay.io/podman/hello:latest... Error: initializing source docker://quay.io/podman/hello:latest: pinging container registry quay.io: Get "https://quay.io/v2/": dial tcp 54.163.152.191:443: i/o timeout
修改DNS后变为解析错误
podman pull quay.io/podman/hello Trying to pull quay.io/podman/hello:latest... Error: initializing source docker://quay.io/podman/hello:latest: pinging container registry quay.io: Get "https://quay.io/v2/": dial tcp: lookup quay.io: Temporary failure in name resolution
重装Docker后仍出现相同解析问题
docker container run hello-world Unable to find image 'hello-world:latest' locally docker: initializing source docker://hello-world:latest: 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. See 'docker run --help'.
环境与已尝试方案
- Windows主机Powershell执行
curl google.com正常,但Ubuntu WSL虚拟机内无网络连接 - 已尝试操作:
podman machine set --rootful- 卸载并重装Hyper-V与WSL
- 修改
resolv.conf添加nameserver 8.8.8.8 - 确认Symantec Endpoint Protection未拦截连接
- 在WSL 1与WSL 2之间切换
- 调试WSL网络相关配置
解决步骤
1. 配置公司代理(核心排查点)
公司笔记本通常存在全局代理,WSL/Podman默认不会继承Windows代理设置:
- 打开WSL终端,临时配置代理:
export HTTP_PROXY=http://<公司代理地址>:<端口> export HTTPS_PROXY=http://<公司代理地址>:<端口> - 如需持久化,将上述命令追加到
~/.bashrc或~/.zshrc文件末尾,执行source ~/.bashrc生效。
2. 固定WSL DNS配置
WSL的resolv.conf会被Windows自动重置,需通过配置文件锁定:
- 在WSL中创建
/etc/wsl.conf,写入:[network] generateResolvConf = false - 关闭WSL(Windows Powershell执行
wsl --shutdown),重新进入WSL后修改/etc/resolv.conf:nameserver 8.8.8.8 nameserver 1.1.1.1
3. 切换WSL网络为桥接模式
绕过Windows NAT限制,直接使用物理网卡网络:
- 在Windows Powershell执行:
wsl --shutdown netsh interface ipv4 set interface "vEthernet (WSL)" metric=0 - 重启WSL后测试
ping google.com是否正常。
4. 验证安全软件规则
即使Symantec日志显示未拦截,仍需确认:
- 临时关闭Symantec Endpoint Protection(需管理员权限),测试镜像拉取。
- 检查Windows防火墙是否允许WSL相关进程出站。
5. 重置Podman Machine
重置Podman虚拟机网络配置:
podman machine stop podman machine rm podman machine init podman machine start
内容的提问来源于stack exchange,提问作者5th
相关产品推荐
相关产品推荐

