当前位置: 代码网 > it编程>开发工具>Docker > docker login 阿里云失败??

docker login 阿里云失败??

2024年08月06日 Docker 我要评论
首先使用 dig 工具找到 阿里云仓库地址(registry.cn-hangzhou.aliyuncs.com) 对应的 IP, 然后再使用 ping 命令检测能否 ping 通该 IP。发现是可以 ping 通的,但是就是在 ping 命令回车后,需要等个几秒钟,才有数据响应。所以我干脆自己把阿里云仓库地址的 IP 和 域名 映射 写到我的 /etc/hosts 文件下, 这样就减少了域名解析的时间。在最后一行添加 阿里云仓库地址 IP 和 域名 的映射,保存退出!再次登录,登录成功。

docker login 阿里云失败??

首先参考 阿里云官方文档《docker登录、推送和拉取失败常见问题

看看是否是下面提到的情况:

在这里插入图片描述

我遇到的情况是超时:

[root@k8snode1 software]# sudo docker login --username=tyleryun registry.cn-hangzhou.aliyuncs.com
password: 
error response from daemon: get https://registry.cn-hangzhou.aliyuncs.com/v2/: net/http: request canceled while waiting for connection (client.timeout exceeded while awaiting headers)
[root@k8snode1 software]#

于是我怀疑是网络连不通 阿里云仓库地址,我就 ping 了一下阿里云地址:
在这里插入图片描述

发现是可以 ping 通的,但是就是在 ping 命令回车后,需要等个几秒钟,才有数据响应。就是我的域名解析可能有点慢,所以导致超时。

所以我干脆自己把阿里云仓库地址的 ip 和 域名 映射 写到我的 /etc/hosts 文件下, 这样就减少了域名解析的时间。

首先使用 dig 工具找到 阿里云仓库地址(registry.cn-hangzhou.aliyuncs.com) 对应的 ip, 然后再使用 ping 命令检测能否 ping 通该 ip。

dig registry.cn-hangzhou.aliyuncs.com

在这里插入图片描述

编辑 /etc/hosts 文件

vi /etc/hosts

在最后一行添加 阿里云仓库地址 ip 和 域名 的映射,保存退出!
在这里插入图片描述
再次登录,登录成功。

[root@k8snode1 software]# sudo docker login --username=tyleryun registry.cn-hangzhou.aliyuncs.com
password: 
warning! your password will be stored unencrypted in /root/.docker/config.json.
configure a credential helper to remove this warning. see
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

login succeeded
[root@k8snode1 software]#
(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com