尝试连接到 https://index.docker.io 时网络超时

Network timed out while trying to connect to https://index.docker.io

我安装了Docker-Toolbox just now while following their webpage

我从 Docker QuickStart Terminal 开始,然后查看以下内容

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/


docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com

bash-3.2$ 

但是当我尝试执行 docker pull hello-world 时,这就是我看到的

bash-3.2$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images. You may want to check your internet connection or if you are behind a proxy.
bash-3.2$ 

怎么了?

我假设您遇到了网络问题。你在代理后面吗?它是否可能过滤与 docker.io 的连接或阻止 docker 用户代理?

我安装了工具箱和 运行 你的测试。它工作正常,在这里:

docker is configured to use the default machine with IP 192.168.99.101
For help getting started, check out the docs at https://docs.docker.com

bash-3.2$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

535020c3e8ad: Pull complete 
af340544ed62: Already exists 
library/hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:d5fbd996e6562438f7ea5389d7da867fe58e04d581810e230df4cc073271ea52
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

bash-3.2$

我今天早上遇到了同样的问题,下面为我解决了这个问题:

$ docker-machine restart default      # Restart the environment
$ eval $(docker-machine env default)  # Refresh your environment settings

这似乎是由于 Docker 虚拟机进入了一个奇怪的状态。有空 github issue here

我在使用 boot2docker 时遇到了同样的问题,并通过以下命令重新启动它来修复它:

boot2docker restart

我 运行 在我的 MAC(主机)上 运行 遇到了这个问题 运行 Docker,在 VBOX 5.10 中使用 Docker 虚拟机。这是一个网络问题。简单的解决方法是将桥接网络添加到 VBOX 图像。您可以使用 VM 随附的 NAT 配置,但您需要将 ssh 端口从 50375 更改为 2375。

更简单的解决方案是在/etc/default/docker文件中添加以下条目

导出http_proxy="http://HOST:PORT/"

并重新启动 docker 服务

服务docker重启

我今天刚刚 运行 进入这个,现有解决方案的 1.10.1 和 none 有效。我尝试重新启动、升级、重新生成证书,...

我注意到我在机器上创建了很多网络。删除它们后:

docker network ls | grep bridge | awk '{print }' | xargs -n1 docker network rm

DNS 又开始工作了。

注意:您可以忽略有关预定义网络的错误

如果您使用代理,设置 HTTP_PROXYHTTPS_PROXY env 是不够的。您应该在创建机器时设置它。

这个参数是--engine-env:

docker-machine create -d "virtualbox" --engine-env HTTP_PROXY=http://<PROXY>:<PORT> --engine-env HTTPS_PROXY=<PROXY>:<PORT> dev
sudo service docker stop
sudo service docker start

适合我..

不知何故,sudo service docker restart 没用

(RHEL7)

On Windows 10.只需右击系统托盘docker图标->设置...->重置->重启Docker

在 Windows 我从工作网络转到家庭网络时发生了这种情况。

求解,运行:

  1. docker-machine stop
  2. docker-machine start
  3. docker-env
  4. "C:\Program Files\Docker Toolbox\docker-machine.exe" env | Invoke-Expression

我在 Windows 10 上安装了没有工具箱的 Docker,所以需要启用 Hyper-V 的版本。

对于 Docker 版本 1.12,我必须进入任务栏,右键单击 Docker 图标,select 设置 -> 网络并将 DNS 服务器设置为固定,这样在 8.8.8.8.

使用 Google 的 DNS 服务器

更改设置后,它终于起作用了。

我 运行 昨天遇到了这个完全相同的问题,none "popular" 的答案(比如将 DNS 修复到 8.8.8.8)对我有用。我最终碰巧遇到了这个 link,并且成功了...... https://github.com/docker/for-win/issues/16

在 Docker for Windows、Windows 10 和 Hyper-V 之间,虚拟网络适配器创建过程中似乎存在问题。具体来说,您最终可能会得到两个 "vEthernet (DockerNAT)" 网络适配器。使用 Get-NetAdapter "vEthernet (DockerNAT)" 进行检查(在提升的 PowerShell 控制台中)。如果结果显示多个适配器,您可以禁用并重命名它:

$vmNetAdapter = Get-VMNetworkAdapter -ManagementOS -SwitchName DockerNAT
Get-NetAdapter "vEthernet (DockerNAT)" | ? { $_.DeviceID -ne $vmNetAdapter.DeviceID } | Disable-NetAdapter -Confirm:$False -PassThru | Rename-NetAdapter -NewName "OLD"

然后打开设备管理器并删除禁用的适配器(出于某种原因,您可以从此处执行此操作,但不能从网络和共享中心适配器视图中删除)。

2016 年 8 月更新

将 Docker 用于 Mac(版本 1.12.0),出现以下形式的问题:

➜  docker pull node
Using default tag: latest
Pulling repository docker.io/library/node
Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/node/images. You may want to check your internet connection or if you are behind a proxy.`enter code here`

通过更新我的 MacBook Pro 无线网络设置以包括以下 DNS 条目解决了这个问题:8.8.8.8

有关详细信息,请参阅此(已过时)issue,其中提供了此处给出的答案。

就我而言,在 Alpine Linux 上安装 docker 我收到错误:

Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/........

在这里使用脚本: https://github.com/docker/docker/blob/master/contrib/download-frozen-image-v2.sh

有效。它使用 curl 下载图像,然后向您展示如何解压和 'docker load' 它。

我在 8.8.8.8 上尝试了静态 DNS 的上述方法并禁用了 ipv6(我不明白代理的事情)并且 none 对我有用。

编辑 2016 年 9 月 8 日:

我最初使用的是 dropbear 而不是 openssh。用 openssh 重新安装 Alpine 解决了这个问题。

下一个问题是 'ApplyLayer exit status 1 stdout: stderr: chmod /bin/mount: permission denied' 拉取时出错。

来自 (nixaid.com/grsec-in-docker/):

To build the Docker image, I had to disable the following grsec protections. Modify the /etc/sysctl.d/grsec.conf as follows:

kernel.grsecurity.chroot_deny_chmod = 0 kernel.grsecurity.chroot_deny_mknod = 0 kernel.grsecurity.chroot_caps = 0 # related to a systemd package/CAP_SETFCAP

在 alpine 的情况下,虽然它是

/etc/sysctl.d/00-alpine.conf

重启

重新启动 Docker 或重新创建图像没有帮助。我重新启动 Windows 没有用。

令人惊讶的是,当我 ssh 进入 运行 容器并执行 curl https://index.docker.io/v1/repositories/library/hello-world/images 时,我得到了一个完全有效的响应。

我在 64 位 Windows 10 Pro 上使用 Docker Toolbox 和 VirtualBox。

我的解决方案是卸载旧的 Docker 版本和 install the new one that uses Hyper-V 而不是 VirtualBox。

现在 Docker 又可以工作了。

在 Windows 7 上,如果您认为自己是代理人

  1. 登录默认机器

    $ docker-machine ssh default
    
  2. 更新配置文件以更新代理设置

    docker@default:~$ sudo vi /var/lib/boot2docker/profile
    
  3. 从下面适当追加

    # replace with your office's proxy environment
    export"HTTP_PROXY=http://PROXY:PORT"
    export"HTTPS_PROXY=http://PROXY:PORT"
    
    # you can add more no_proxy with your environment.
    export"NO_PROXY=192.168.99.*,*.local,169.254/16,*.example.com,192.168.59.*"
    
  4. 退出

    docker@default:~$ exit
    
  5. 重启docker机器

    docker-machine restart default
    
  6. 更新环境设置

    eval $(docker-machine env default)
    

以上步骤略有调整,但如故障排除指南中所述:https://docs.docker.com/toolbox/faqs/troubleshoot/#/update-varlibboot2dockerprofile-on-the-docker-machine

如果您使用代理,请使用以下命令

sudo mkdir /etc/systemd/system/docker.service.d

sudo cd /etc/systemd/system/docker.service.d

sudo vi http-proxy.conf
[Service]

Environment=HTTP_PROXY=http://proxy-server-ip:port" "NO_PROXY=localhost,127.0.0.1"

sudo systemctl daemon-reload 

sudo systemctl show --property=Environment docker

sudo systemctl restart docker

如果你能获取最新的,试试这个 ubuntu

sudo docker run -it ubuntu bash

无法在本地找到图像ubuntu:latest

latest: Pulling from library/ubuntu b3e1c725a85f: Pull complete

4daad8bdde31: Pull complete

63fe8c0068a8: Pull complete

4a70713c436f: Pull complete

bd842a2105a8: Pull complete

Digest:

sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a

Status: Downloaded newer image for ubuntu:latest

终于对我有用了:)

另一种情况:如果您的 docker 网络适配器被禁用,它将失败并出现此错误。适配器名为 "vEthernet (DockerNAT)" 或类似名称。显然这个适配器以某种方式参与了正常的 docker 拉行为。启用它来解决问题。

为 docker 服务创建一个 systemd drop-in 目录:

$ sudo mkdir -p /etc/systemd/system/docker.service.d

创建一个名为 /etc/systemd/system/docker.service.d/http-proxy.conf 的文件,添加 HTTP_PROXY 环境变量:

[服务]

Environment="HTTP_PROXY=http://proxy.example.com:80/"

希望对您有所帮助

参考https://docs.docker.com/network/proxy/ 对我来说,没有 http:// 或 https:// 前缀的代理设置有效。 例如: PROXY:PORT

或带/后缀带http://或https://前缀 即: http://PROXY:PORT/