如果无法访问 Docker Hub,可以尝试以下解决方案逐步排查:
8.8.8.8 或 114.114.114.114)。
/etc/resolv.conf 或通过 nmcli 修改。bash
# Windows
ipconfig /flushdns
# Linux (systemd-resolved)
sudo systemctl restart systemd-resolved
# macOS
sudo killall -HUP mDNSResponder/etc/docker/daemon.json):
json
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com"
]
}
重启 Docker:
bash
sudo systemctl restart dockerbash
docker pull registry.docker-cn.com/library/nginx:latest/etc/sysctl.conf,添加:
ini
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1bash
sudo sysctl -pbash
# Linux
sudo systemctl stop firewalld
# Windows
netsh advfirewall set allprofiles state offhosts 文件未被篡改(如恶意软件可能劫持域名):
C:\Windows\System32\drivers\etc\hosts/etc/hostsdocker.io、hub.docker.com 相关的行。curl 或 ping 测试连通性:
bash
ping hub.docker.com
curl -v https://hub.docker.comdocker save/docker load 从其他机器导入)。根据具体错误信息(如 Connection timed out、TLS handshake failed)可进一步针对性解决。