执行docker pull nginx: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)
执行docker run -d nginx:latest命令时,错误提示:
Unable to find image 'nginx:latest' locally
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'.
原因是由于,虚拟机网络问题导致。
解决方法:
1、配置daemon.json文件,在/etc/docker/daemon.json下,没有则创建。
#创建daemon.json
touch daemon.json
# 编辑daemon.json
vi /etc/docker/daemon.json
2、添加配置
添加第一种配置即可
{
"registry-mirrors": [
"https://registry.cn-hangzhou.aliyuncs.com",
"https://swr.cn-north-4.myhuaweicloud.com",
"https://mirror.ccs.tencentyun.com"
],
"dns": ["8.8.8.8", "8.8.4.4"],
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}
}
或
{
"registry-mirrors": [
"https://docker.211678.top",
"https://docker.1panel.live",
"https://hub.rat.dev",
"https://docker.m.daocloud.io",
"https://do.nark.eu.org",
"https://dockerpull.com",
"https://dockerproxy.cn",
"https://docker.awsl9527.cn"
]
}
或
{
"registry-mirrors": ["https://docker.1panel.live"]
}
或
{
"registry-mirrors": ["https://docker.m.daocloud.io"]
}
3、保存退出,并重启docker
# 保存退出,esc 冒号 wq
:wq
# 重启docker
systemctl daemon-reload
systemctl restart docker
再去下载相关容器镜像。