【云原生Docker | 报错01】大力出奇迹,解决docker_Error response from daemon_Get “https://registry-1.docker.io/v2/“

发布于:2025-02-10 ⋅ 阅读:(56) ⋅ 点赞:(0)

🗺️博客地图

📍一、报错发现

📍二、解决方式

🖈1、Linux操作系统

🖈2、Windows操作系统

📍三、结果测试 


一、报错发现

使用docker pull或者docker run时,从hub库中拉取下载镜像时报错,具体如下:

​docker: 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).
See 'docker run --help'.

问题是因为docker镜像源无法连接的问题,需要配置国内的docker源

二、解决方式

1、Linux操作系统

① 修改配置文件 /etc/docker/daemon.json,大力出奇迹,修改后内容如下:都加!都加!不信没一个可以用的

{
  "runtimes": {
    "nvidia": {
      "args": [],
      "path": "nvidia-container-runtime"
    }
  },
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://cr.console.aliyun.com",
    "https://mirror.ccs.tencentyun.com",
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn/",
    "https://yxzrazem.mirror.aliyuncs.com",
    "https://docker.kubesre.xyz",
    "https://dc.j8.work",
    "https://docker.registry.cyou",
    "https://docker.hlyun.org",
    "https://docker.chenby.cn",
    "https://docker.jsdelivr.fyi",
    "https://docker-mirrors.mjjman.com",
    "https://docker.kubesre.xyz",
    "https://huecker.io",
    "https://dockerhub.timeweb.cloud",
    "https://docker.registry.cyou",
    "https://docker-cf.registry.cyou",
    "https://dockercf.jsdelivr.fyi",
    "https://dockertest.jsdelivr.fyi",
    "https://2a6bf1988cb6428c877f723ec7530dbc.mirror.swr.myhuaweicloud.com",
    "https://docker.m.daocloud.io",
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com",
    "https://your_preferred_mirror",
    "https://dockerhub.icu",
    "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"
  ],
  "insecure-registries": [],
  "debug": false,
  "experimental": false,
  "features": {
    "buildkit": true
  },
  "builder": {
    "gc": {
      "enabled": true,
      "defaultKeepStorage": "20GB"
    }
  }
}

② 修改后配置文件,重启docker服务,命令如下:

[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker

2、Windows操作系统

打开docker Windows桌面版本,点击小齿轮配置--选择Docker Engine--将上文Linux daemon.json 文件内容复制粘贴到方框内--点击保存

三、结果测试 

拉取一个镜像测试一下

[root@localhost ~]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:5b3cc85e16e3058003c13b7821318369dad01dac3dbb877aac3c28182255c724
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

完美,打完收工!


网站公告

今日签到

点亮在社区的每一天
去签到