Docker 拉取镜像报错Error response from daemon: Get “https://registry-1.docker.io/…:net/http: TLS timeout

2022年7月4日09:16:34

第一次使用docker,想在虚拟机上run一个hello-world镜像,结果又出现了timeout错误提示,99%的可能性就是连接外网超时,然而我用阿里云的服务器发现没有丝毫问题,速度还挺快......

Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/library/hello-world/manifests/sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38": net/http: TLS handshake timeout.
See 'docker run --help'.

在网上看到有人说用dig @114.114.114.114 registry-1.docker.io 查远程仓库IP地址改hosts,但我发现其中的每一个IP地址都ping不通,估计也都是国外的IP

以下方法实测可行

第一步:修改daemon.json文件(CentOS 7.9安装完没有这文件,就直接创建)

vim /etc/docker/daemon.json

往该文件内加入以下内容

{
    "registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
}

第二步:重启 docker 服务

systemctl daemon-reload

systemctl restart docker


或者可以去阿里云镜像加速服务那里免费获取加速地址

再次运行镜像,发现我又可以了~

  • 作者:AdamShyly
  • 原文链接:https://blog.csdn.net/Adam_captain/article/details/123778066
    更新时间:2022年7月4日09:16:34 ,共 711 字。