【Docker问题】CentOS安装docker后运行报错Get https://registry-1.docker.io/v2/

2023-05-16

整理一下所有遇到这个问题的解决办法,最终已解决!!!!

1、先确定虚拟机能够连接公网,网络适配器选择NAT

[root@localhost etc]# ping www.baidu.com
PING www.wshifen.com (103.235.46.39) 56(84) bytes of data.
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=2 ttl=128 time=117 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=3 ttl=128 time=80.9 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=4 ttl=128 time=105 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=6 ttl=128 time=116 ms

2、如果在拉取镜像时出现如下图报错,考虑先docker login

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)

3、如果docker login 报错如下

[root@localhost etc]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: kaerdocker
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)

 4、多数是国外镜像源的网络限制导致,使用国内镜像源即可,但是网络上一大堆没用的,直接上命令

#####https://registry.docker-cn.com是可用的##########

[root@localhost etc]# vim /etc/docker/daemon.json
{
"registry-mirrors":["https://docker.mirrors.ustc.edu.cn","https://registry.docker-cn.com"]
}

#####

[root@localhost etc]# systemctl daemon-reload 

[root@localhost etc]# systemctl restart docker

[root@localhost etc]# docker login

如果报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout试着重新寻找镜像源吧

[root@localhost etc]# docker run hello-world

如果以上还不能解决,下面总结下网络搜索下出现的解决方案(本人未使用到)

##########https://github.com/docker/for-win/issues/1534摘抄该链接

mkdir -p /etc/systemd/system/docker.service.d
nano /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://USER:PASSWD@SERVER:PORT/"
Environment="HTTPS_PROXY=http://USER:PASSWD@SERVER:PORT/"

systemctl daemon-reload
systemctl restart docker

###########变更DNS###########

[root@localhost etc]# vim /etc/resolv.conf

# Generated by NetworkManager
search localdomain
#nameserver 172.20.10.4

nameserver 8.8.8.8
nameserver 8.8.4.4

结束,继续docker之旅。

 

保存下推荐资源:http://guide.daocloud.io/dcs/daocloud-9153151.html

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【Docker问题】CentOS安装docker后运行报错Get https://registry-1.docker.io/v2/ 的相关文章

随机推荐