Docker 拉取失败,请求在等待连接时被取消

问题描述 投票:0回答:2

我正在尝试将映像拉取到默认的 docker 机器。但我总是得到

docker@default:/etc$ docker run hellow-world
Unable to find image 'hellow-world: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'.
docker@default:/etc$

即使我给出 --dns 选项同样的错误

docker@default:/etc$ docker run hellow-world --dns=8.8.8.8
Unable to find image 'hellow-world: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'.
docker@default:/etc$

尝试将 DNS 添加到默认机器的 config.json

"EngineOptions": {
    "Dns": [
        "8.8.8.8",
        "8.8.4.4"
    ]
}

resolv.conf 在默认机器中有以下条目

docker@default:/etc$
docker@default:/etc$ cat /etc/resolv.conf
search <company name>
nameserver 10.0.2.3
docker@default:/etc$

这台机器位于代理后面,我正在使用 kitematic 创建默认机器

Kitematic 由自定义脚本启动,该脚本将设置代理并启动 kitematic

推荐和所有图像在 kitematic 开始时显示。但无法拉取任何图像

创建新机器也会发出警告

PS C:\Program Files\Docker Toolbox\kitematic> docker-machine create -d virtualbox --engine-opt dns=8.8.8.8 test
Running pre-create checks...
(test) Unable to get the latest Boot2Docker ISO release version:  Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 192.30.253.116:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Creating machine...
(test) Unable to get the latest Boot2Docker ISO release version:  Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 192.30.253.116:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

使用

--dns
选项创建的机器也有
/etc/resolv.conf
,而不是
8.8.8.8

docker@test:~$
docker@test:~$ cat /etc/resolv.conf
search <company name>
nameserver 10.0.2.3
docker@test:~$

PS:将 HTTP_PROXY 添加到 /var/lib/boot2docker/profile 后问题解决

docker boot2docker docker-machine
2个回答
2
投票

找到解决方案

无论是 将

HTTP_PROXY
添加到
/var/lib/boot2docker/profile

使用

--engine-env HTTP_PROXY=IP:PORT

创建 docker 机器

0
投票

当从内部港口(在/etc/docker/daemon.json中定义为唯一的注册表镜像,因为外部流量不允许)提取图像时,我收到错误“获取https://registry-1” .docker.io/v2/:net/http:等待连接时取消请求(等待标头时超出了 Client.Timeout)。”下载并提取一些层后成功

原因:磁盘空间不足
解决方案:增加磁盘空间(之后registry-1.docker.io的超时消失了)

我不知道为什么 docker 试图从 docker 配置中未定义的注册表中提取数据。

journalctl -u dockerd
中,它显示类似“level=info ...错误后尝试拉取下一个端点...设备上没有剩余空间” 我不清楚为什么没有显示为错误。也许存在一种内部机制,在从注册表中获取图层后,无论出于何种原因失败,它都会尝试回退到registry-1.docker.io

© www.soinside.com 2019 - 2024. All rights reserved.