文章目录
一级目录
bash
docker pull hello-world
Using default tag: latest
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)
明明已在/etc/docker/daemon.json里,配置了专属于自己的阿里云镜像加速器,如下:
bash
{
"registry-mirrors": ["https://你的新加速器地址.mirror.aliyuncs.com"]
}
为啥提示上述问题,就是因为:2024年7月2日阿里云公告镜像加速器仅支持内网使用,也就是说你要购买阿里云的服务器,在他们的服务器上才能使用了。
所以说,访问https://你的新加速器地址.mirror.aliyuncs.com时,就走不通了,就会走docker官方默认兜底的镜像仓库地址:https://registry-1.docker.io/v2/,又因为这个https://registry-1.docker.io/v2/地址是国外的,国内经常访问不通。
替代方案(在/etc/docker/daemon.json里覆盖添加以下内容):
bash
{
"registry-mirrors": [
"https://proxy.1panel.live",
"https://docker.1panel.top",
"https://docker.m.daocloud.io",
"https://docker.1ms.run",
"https://docker.ketches.cn"
]
}
如果公司用的是网络,需要配置代理才能访问外网:
请添加以下配置:
sudo vim /etc/systemd/system/docker.service.d/proxy.conf (docker作为一个软件可能不会使用全局的代理配置,加上以下保险一些)
bash
[Service]
Environment="HTTP_PROXY=http://xxxxxx:8080"
Environment="HTTPS_PROXY=http://xxxxxxxx:8080"
Environment="NO_PROXY=localhost,127.0.0.1,.your-internal-domain.com"
和
全局临时设置(重启失效),如果上述的配置不生效,就用下面的,或着两个地方都配置
bash
export http_proxy=http://xxxx:8080
export https_proxy=http://xxxxxx:8080