【docker 拉取镜像超时问题】

发布于:2024-11-29 ⋅ 阅读:(23) ⋅ 点赞:(0)

问题描述

centosStream8上安装docker,使用命令sudo docker run hello-world 后出现以下错误:
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).

解决方法

配置仓库镜像,方法如下:

  1. 执行命令sudo vi /etc/docker/daemon.json

  2. 在打开的文件中追加以下内容:

       {
       	  "registry-mirrors": [
       	    "https://mirror.ccs.tencentyun.com",
       	    "https://registry.docker-cn.com",
       	    "https://docker-proxy.741001.xyz",
       	    "https://alzgoonw.mirror.aliyuncs.coma",
       	    "https://hub-mirror.c.163.com",
       	    "https://docker.registry.cyou",
       	     # 以下是追加的仓库
       	    "https://docker-cf.registry.cyou",
       	    "https://dockercf.jsdelivr.fyi",
       	    "https://docker.jsdelivr.fyi",
       	    "https://dockertest.jsdelivr.fyi",
       	    "https://mirror.aliyuncs.com",
       	    "https://dockerproxy.com",
       	    "https://mirror.baidubce.com",
       	    "https://docker.m.daocloud.io",
       	    "https://docker.nju.edu.cn",
       	    "https://docker.mirrors.sjtug.sjtu.edu.cn",
       	    "https://docker.mirrors.ustc.edu.cn",
       	    "https://mirror.iscas.ac.cn",
       	    "https://docker.rainbond.cc"
       	  ]
       }
    
  3. 保存后退出。

  4. 重启:

    • sudo systemctl daemon-reload
    • sudo systemctl restart docker

注意
registry-mirrors中的仓库名称不能存在重复的,否则重启docker时会失败。