docker login 阿里云失败??

docker login 阿里云失败??

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

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

我遇到的情况是超时:

bash 复制代码
[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。

bash 复制代码
dig registry.cn-hangzhou.aliyuncs.com

编辑 /etc/hosts 文件

bash 复制代码
vi /etc/hosts

在最后一行添加 阿里云仓库地址 IP 和 域名 的映射,保存退出!

再次登录,登录成功。

bash 复制代码
[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]#
相关推荐
OKUNP4 小时前
Docker高级管理--容器通信技术与数据持久化
docker·容器·php
用户6855449692737 小时前
第一周作业
docker
星辰云-10 小时前
【超详细】CentOS系统Docker安装与配置一键脚本(附镜像加速配置)
linux·docker·centos
果子⌂13 小时前
Docker-构建镜像并实现LNMP架构
mysql·nginx·docker·容器·架构·php
无敌糖果13 小时前
K8S数据流核心底层逻辑剖析
docker·容器·kubernetes·k8s架构·底层逻辑·k8s数据流
骇客野人14 小时前
阿里云和腾讯云RocketMQ 发消息和消费消息客户端JAVA接口
阿里云·java-rocketmq·腾讯云
Trust yourself24314 小时前
使用阿里云/腾讯云安装完成mysql使用不了
mysql·阿里云·腾讯云
攀小黑14 小时前
阿里云 使用TST Token发送模板短信
java·阿里云
运维成长记14 小时前
阿里云错题集分享
阿里云·云计算
云资源服务商14 小时前
探秘阿里云消息队列:解锁分布式系统的异步通信奥秘
阿里云·中间件·云计算