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]#
相关推荐
学习3人组3 小时前
Docker 从本地Label-studio导入 tar 镜像包
运维·docker·容器
羑悻的小杀马特3 小时前
Docker-Android 容器化 + cpolar 穿透,完善异地调试
android·运维·docker·容器·cpolar
Y.O.U..3 小时前
Kubernetes-网络策略
网络·容器·kubernetes
lpfasd1234 小时前
Docker 使用注意事项:从磁盘爆满到安全实践的完整避坑指南
安全·docker·容器
勇气要爆发5 小时前
Docker+Ollama+LangChain:从零搭建企业级“隐私优先”本地 RAG 知识库 (附源码)
docker·容器·langchain·lora·rag·ollama·llama 3
Hello.Reader7 小时前
Flink 2.2 Docker 部署Session / Application / SQL Client 一把梭(含 Compose、插件、连接器与踩坑点)
sql·docker·flink
水上冰石8 小时前
Kubernetes Ingress + TLS 故障排查全流程
云原生·容器·kubernetes
岁岁种桃花儿8 小时前
K8s核心流量管理:Ingress与Service深度解析及实战对比
云原生·容器·kubernetes
市安8 小时前
docker命令知识点1
运维·docker·云原生·容器·eureka
学习3人组9 小时前
Docker run 挂载本地两个目录到容器内的写法(核心规则+实操示例)
运维·docker·容器