当 docker login
命令失败时,可能是多种原因导致的。以下是常见问题及解决方案:
Error response from daemon: Get "https://registry-1.docker.io/v2/": unauthorized: incorrect username or password
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Error response from daemon: Get "https://registry-1.docker.io/v2/": x509: certificate signed by unknown authority
sudo apt-get install --reinstall ca-certificates
(Ubuntu/Debian)Error saving credentials: error storing credentials - err: exit status 1, out: `not implemented`
bash
echo '{"credsStore":"pass"}' > ~/.docker/config.json
或
bash
echo '{"credsStore":"file"}' > ~/.docker/config.json
pass
工具)Error response from daemon: Get "https://private.registry/v2/": http: server gave HTTP response to HTTPS client
json
// /etc/docker/daemon.json
{
"insecure-registries" : ["private.registry:5000"]
}
sudo systemctl restart docker
检查Docker服务状态:
sudo systemctl status docker
查看详细错误日志:
journalctl -u docker --no-pager -n 50
尝试基础连接测试:
curl -v https://registry-1.docker.io/v2/
清除现有凭证:
rm ~/.docker/config.json
使用更详细的日志:
docker --debug login
如果问题仍然存在,请提供具体的错误信息和您尝试登录的仓库类型(Docker Hub、私有仓库等),我可以提供更有针对性的建议。