这个错误仍然是 DNS 解析失败导致的,Docker 无法解析阿里云镜像仓库的域名 registry.cn-hangzhou.aliyuncs.com。可以按以下步骤彻底解决 DNS 问题:
检查并恢复 systemd-resolved 服务(推荐方法):
确保 systemd-resolved 服务正常运行
sudo systemctl start systemd-resolved
sudo systemctl enable systemd-resolved
重建 resolv.conf 符号链接
sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
手动配置 DNS 服务器:
编辑 systemd-resolved 配置文件:
sudo nano /etc/systemd/resolved.conf
在文件中添加以下内容(取消注释并修改):
[Resolve]
DNS=8.8.8.8 114.114.114.114
FallbackDNS=223.5.5.5 180.76.76.76
重启服务使配置生效:
sudo systemctl restart systemd-resolved
验证 DNS 解析:
先测试域名是否能正常解析:
nslookup registry.cn-hangzhou.aliyuncs.com
如果显示正常的 IP 地址,则说明 DNS 配置成功。
再次尝试拉取镜像:
docker pull registry.cn-hangzhou.aliyuncs.com/dpanel/dpanel:latest
如果以上方法仍不奏效,可能是网络环境限制(如防火墙、安全组阻止了 DNS 端口 53),需要检查网络策略是否允许 UDP 53 端口的出站连接。