面临大手,普通Docker用户对源与网络问题的探索

面临大手,普通Docker用户对源与网络问题的探索

Aoi Komiya Lv3

报错

build docker的时候遇到如下报错:

1
ERROR: failed to solve: python:3.10: failed to do request: Head "https://registry.docker-cn.com/v2/library/python/manifests/3.10?ns=docker.io": EOF

联想起六月中旬的国内docker源集体下架事件,结合对报错的分析,很明显,docekr的cn源已挂。

去查看了一下我的docker源配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}

发现我此前添加的三个docker源,都是国内源哈哈。

我需要为自己寻找一个解决方案。

解决方案

方案1 - 换源

google到八方网域 的这篇doc,换成了以下的docker源,24-10-6亲测可用。

1
2
3
4
5
6
7
8
9
10
{
"registry-mirrors": [
"https://do.nark.eu.org",
"https://dc.j8.work",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}

方案2 - 代理

下文摘自:Daemon configuration

You may configure proxy behavior for the daemon in the daemon.json file, or using CLI flags for the --http-proxy or --https-proxy flags for the dockerd command. Configuration using daemon.json is recommended.

1
2
3
4
5
6
7
{
"proxies": {
"http-proxy": "http://proxy.example.com:3128",
"https-proxy": "https://proxy.example.com:3129",
"no-proxy": "*.test.example.com,.example.org,127.0.0.0/8"
}
}

中文相关资料参考此文

方案3 - 搭建私有仓库

搭建私有Docker镜像仓库是个不错的选择,我猜测大部分企业也是会自建镜像仓库的,毕竟很方便(

但对于个人来说,成本大于收益,所以我只在这边记录引用此文 供读者参考。

  • Title: 面临大手,普通Docker用户对源与网络问题的探索
  • Author: Aoi Komiya
  • Created at: 2024-07-30 15:20:12
  • Updated at: 2024-10-06 15:23:11
  • Link: https://blog.komiya.monster/2024/07/30/docker_mirror_solution/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
面临大手,普通Docker用户对源与网络问题的探索