Windows11下Rancher Desktop拉取Docker镜像失败及代理配置问题
Windows11下Rancher Desktop拉取Docker镜像失败,代理配置不生效
错误情况
执行docker pull postgres时出现连接重置错误:
docker pull postgres Using default tag: latest Error response from daemon: Get "https://registry-1.docker.io/v2/": read tcp 172.17.20.41:60764->54.227.20.253:443: read: connection reset by peer
已尝试在.docker/config.json中配置代理,但docker info输出未显示任何代理设置,完整docker info信息如下:
docker info Client: Context: default Debug Mode: false Plugins: compose: Docker Compose (Docker Inc., v2.14.0) Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 8 Server Version: 20.10.20 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2 Default Runtime: runc Init Binary: docker-init containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc version: 5fd4c4d144137e991c4acebb2146ab1483a97925 init version: Security Options: seccomp Profile: default Kernel Version: 5.15.167.4-microsoft-standard-WSL2 Operating System: Rancher Desktop WSL Distribution OSType: linux Architecture: x86_64 CPUs: 8 Total Memory: 7.607GiB Name: CSILT6VPM8S3 ID: RJWW:NPBV:64ZH:NGUQ:I4IG:BSQD:TCKH:EE7O:NTJT:2I4Z:FL5L:UBOS Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false WARNING: No blkio throttle.read_bps_device support WARNING: No blkio throttle.write_bps_device support WARNING: No blkio throttle.read_iops_device support WARNING: No blkio throttle.write_iops_device support
解决步骤
1. 配置Rancher Desktop内置代理
Rancher Desktop依赖WSL2运行,仅修改.docker/config.json无法让daemon识别代理,需在Rancher Desktop设置中配置:
- 打开Rancher Desktop,点击右上角设置图标
- 切换到Network标签页
- 在Proxy区域填入代理地址(格式:
http://代理IP:端口),并添加无需代理的地址(如localhost,127.0.0.1) - 保存设置后重启Rancher Desktop
2. 确保WSL2环境代理正常
WSL2独立于Windows网络环境,需单独配置代理:
- 打开WSL2终端,执行临时代理命令:
export HTTP_PROXY=http://代理IP:端口 export HTTPS_PROXY=http://代理IP:端口 export NO_PROXY=localhost,127.0.0.1,本地域名后缀 - 测试代理连通性:
curl https://registry-1.docker.io/v2/,返回正常则代理有效 - 如需永久生效,将上述命令追加到
~/.bashrc或~/.zshrc文件中,重启终端即可
3. 修正.docker/config.json格式
确保代理配置格式正确,示例如下:
{ "proxies": { "default": { "httpProxy": "http://代理IP:端口", "httpsProxy": "http://代理IP:端口", "noProxy": "localhost,127.0.0.1,*.local" } } }
配置完成后,通过Rancher Desktop重启Docker服务
4. 排查防火墙/安全软件拦截
连接重置错误可能是防火墙或安全软件阻断了Docker的网络请求,尝试临时关闭防火墙,或将Rancher Desktop加入安全软件白名单后再测试拉取镜像
内容的提问来源于stack exchange,提问作者raffa50
相关产品推荐
相关产品推荐

