Docker登录遇x509证书不匹配错误,求解决方案
执行命令 docker login -u "username" -p "password" 时,出现以下错误:
Error response from daemon: Get "https://registry-1.docker.io/v2/":
Get "https://auth.docker.io/token?account=alizne&client_id=docker&offline_token=true&service=registry.docker.io":
x509: certificate is valid for *.transperfect.com, transperfect.com, not auth.docker.io
以下是针对性的解决步骤:
修正DNS配置
错误表明请求被重定向到了transperfect.com的服务器,大概率是DNS劫持或污染导致。手动切换DNS服务器为公共DNS,比如8.8.8.8(谷歌)或1.1.1.1(Cloudflare),之后清除本地DNS缓存:- Windows:运行
ipconfig /flushdns - Linux/macOS:运行
sudo systemd-resolve --flush-caches(不同系统可能有对应缓存清除命令)
- Windows:运行
清理残留代理配置
即使关闭VPN,系统或Docker的代理配置可能仍有残留:- 检查Docker配置文件(通常是
/etc/docker/daemon.json),如果存在多余的http-proxy/https-proxy配置,删除后重启Docker服务:sudo systemctl restart docker - 检查系统全局代理设置,确保没有指向异常地址的代理规则
- 检查Docker配置文件(通常是
重置Docker网络
Docker网络配置可能被篡改,执行以下命令重置:docker network prune sudo systemctl restart docker检查hosts文件
打开本地hosts文件(Windows路径:C:\Windows\System32\drivers\etc\hosts;Linux/macOS路径:/etc/hosts),查看是否存在将auth.docker.io或registry-1.docker.io指向transperfect.com相关IP的条目,如有则删除并保存。
内容的提问来源于stack exchange,提问作者Ali Zeinodin

