posts - 52,comments - 30,views - 13万

解决Error Get "https://registry-1.docker.io/v2/":环境报错问题~亲测有效

最近在使用ubuntu 20.04部署docker等程序服务 发现 使用docker 拉取镜像时环境报错 mysql Error Get "https://registry-1.docker.io/v2/":环境报错问题 找了很多贴子

有人说之前的资源地址被墙了,可以使用更换成国内镜像源 和 添加代理地址的方式

经过我的不断尝试 找到此问题的解决方案

通过添加国内镜像代理 成功解决 已下是解决方案

 

1.进入 Docker 配置文件,通常位于 /etc/docker/daemon.json

sudo vi /etc/docker/daemon.json

添加已下内容

{
  "registry-mirrors":
    [
      "https://docker.m.daocloud.io/",
      "https://huecker.io/",
      "https://dockerhub.timeweb.cloud",
      "https://noohub.ru/",
      "https://dockerproxy.com",
      "https://docker.mirrors.ustc.edu.cn",
      "https://docker.nju.edu.cn",
      "https://xx4bwyg2.mirror.aliyuncs.com",
      "http://f1361db2.m.daocloud.io",
      "https://registry.docker-cn.com",
      "http://hub-mirror.c.163.com",
      "https://docker.mirrors.ustc.edu.cn"
    ]
}

 

修改完成后,重启 Docker 服务:

sudo systemctl restart docker

这个镜像有些环境下可能在重新加载时,有报配置文件错误的情况,这种情况下,不要慌使用2分法 对以上镜像 分块加入到环境中,测试(我一同事就只添加了上面一半的镜像就解决了问题)
 

2.增加请求超时时间:可以尝试增加 Docker 的默认超时时间。例如在 WSL 的 Ubuntu 环境下,可以增加 Docker 的客户端超时时间:

  export DOCKER_CLIENT_TIMEOUT=120

  export COMPOSE_HTTP_TIMEOUT=120

3.有时候 DNS 配置可能会导致网络请求超时。可以尝试修改 /etc/resolv.conf 文件,将 DNS 服务器改为公共 DNS,比如

      sudo vi /etc/resolv.conf

  删掉默认的nameserver地址在后面增加

  nameserver 8.8.8.8

  nameserver 8.8.4.4

      从新加载

systemctl restart systemd-resolved.service

4.重新安装或更新 Docker:可能是由 Docker 的安装版本引起的。可以尝试更新 Docker

   sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io

最后大功告成

 

后续我这边在服务器上装了GPU支持,然后配置文件有所变化如下,格式是这样哈

复制代码
{
    "dns": ["8.8.8.8", "8.8.4.4"],
    "registry-mirrors": [
        "https://docker.m.daocloud.io/",
        "https://huecker.io/",
        "https://dockerhub.timeweb.cloud",
        "https://noohub.ru/",
        "https://dockerproxy.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://docker.nju.edu.cn",
        "https://xx4bwyg2.mirror.aliyuncs.com",
        "http://f1361db2.m.daocloud.io",
        "https://registry.docker-cn.com",
        "http://hub-mirror.c.163.com"
    ],
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}
复制代码

 完了之后 配置重新加载

sudo systemctl daemon-reload

docker 重新启动

sudo systemctl restart docker

大功告成!

 

 

参考帖子:

https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6

posted on   白码一号  阅读(80371)  评论(6编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示