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

无法从Docker公共仓库拉取镜像的技术求助

Docker公共仓库无法拉取镜像问题

环境信息

  • 系统:WSL 2 上的 Ubuntu 22.04,主机为 Windows 11 专业版(22H2,内部版本 22621.819)
  • Docker 版本:
$ docker -v
Docker version 20.10.19, build d85ef84
  • 网络状态:在家办公,未修改网络配置,无 VPN/代理,fast.com 测速 540Mbps,截至昨天一切正常

已尝试的操作

  • 将默认 DNS 修改为谷歌 DNS(8.8.8.8)
  • 重启 Docker 守护进程
  • 重启 WSL
  • 重启计算机
  • 切换至 4G 网络
  • 在 Windows CMD 执行 ipconfig /flushdns 刷新本地 DNS 缓存
  • 查阅 Docker 官网的服务状态及规则变更公告

错误现象

执行 docker pull hello-world 时出现以下错误:

$ docker pull hello-world
Using default tag: latest
Error response from daemon:
Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on <my_ip>:53: read udp <my_ip>:42896-><my_ip>:53: read: connection refused

解决建议

1. 锁定 WSL 内的 DNS 配置

WSL 默认会自动覆盖 /etc/resolv.conf,导致手动设置的 DNS 失效:

  • 进入 WSL 终端,编辑 /etc/resolv.conf,确保内容包含:
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    
  • 执行 sudo chattr +i /etc/resolv.conf 锁定文件,避免被自动重置

2. 测试 DNS 解析连通性

在 WSL 终端执行:

nslookup registry-1.docker.io 8.8.8.8

如果能正常返回 IP,说明是本地 DNS 服务故障;如果无法解析,检查 WSL 的网络路由是否正常。

3. 重置 WSL 网络

在 Windows CMD 中执行:

wsl --shutdown

然后打开「网络和共享中心」,找到名为 vEthernet (WSL) 的虚拟网卡,右键禁用后再启用,重新启动 WSL。

4. 配置 Docker 守护进程的 DNS

新建或编辑 /etc/docker/daemon.json 文件:

{
  "dns": ["8.8.8.8", "8.8.4.4"]
}

保存后重启 Docker:

sudo systemctl restart docker

5. 排查防火墙/安全软件拦截

临时关闭 Windows Defender 防火墙或第三方安全软件,测试是否能拉取镜像。如果恢复正常,需为 Docker 添加允许网络请求的规则。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 07:55:30