docker安装在virtualbox中的ubuntu,不能拉图像

我有安装Ubuntu 14.04.5作为guest虚拟机在virtualbox 5.0.26在Windows 10上运行。我不知道任何与Ubuntu安装问题,它似乎运行良好,并有桥接互联网连接,所以得到自己的IP。

我已经安装了泊坞窗,遵循docker docs for linux的指导 。 安装进行没有任何错误罚款和docker守护进程开始确定。 这是docker信息:

root@ubuntu-z9:~# docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 1.12.0 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 0 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: overlay bridge host null Swarm: inactive Runtimes: runc Default Runtime: runc Security Options: apparmor Kernel Version: 4.2.0-27-generic Operating System: Ubuntu 14.04.5 LTS OSType: linux Architecture: x86_64 CPUs: 10 Total Memory: 31.42 GiB Name: ubuntu-z9 ID: 7MPO:OHFW:3OBJ:KUVX:3YCS:XP4U:RE6W:SFC3:O4KK:GJJU:M6WJ:HYLY Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ WARNING: No swap limit support Insecure Registries: 127.0.0.0/8 

该机器可以看到互联网罚款,并从浏览器访问hub.docker.com。

但是,当我运行简单的hello-worldtesting时,守护进程将挂起

 root@ubuntu-z9:~# docker run hello-world Unable to find image 'hello-world:latest' locally 

超时。

我可以运行docker机没有任何问题在主机的Windows 10机器,所以我相信这个问题在于我在虚拟机和docker中的Ubuntu机器的设置。

这是Ubuntu客户机上的docker守护进程的日志输出:

 $ docker pull hello-world DEBU[0093] Calling POST /v1.24/images/create?fromImage=hello-world&tag=latest DEBU[0093] Trying to pull hello-world from https://registry-1.docker.io v2 DEBU[0094] Increasing token expiration to: 60 seconds ERRO[0494] Error trying v2 registry: error parsing HTTP 408 response body: invalid character '<' looking for beginning of value: "<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n\n" ERRO[0494] Attempting next endpoint for pull after error: error parsing HTTP 408 response body: invalid character '<' looking for beginning of value: "<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n\n" DEBU[0494] Skipping v1 endpoint https://index.docker.io because v2 registry was detected ERRO[0494] Handler for POST /v1.24/images/create returned error: error parsing HTTP 408 response body: invalid character '<' looking for beginning of value: "<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n\n" 

任何build议,在未来的方式来诊断或解决这个问题?

非常感谢。

这是一个简单的问题,毫无疑问是在某个地方logging,但我错过了。 我在这里发表一个答案,以防其他人有相同的情况。

virtualbox操作系统(在我的情况下是Ubuntu的)必须有一个NATnetworking适配器和NAT适配器必须比桥接适配器(如果你有一个)更高的优先级。 你不需要一个桥接适配器来运行docker(但是如果你想让virtualbox在你的本地networking上有一个ip,那么你需要添加一个桥接适配器。)

运行docker的VirtualBoxconfiguration示例:

  1. VBox适配器1:NAT(eth0),VBox适配器2:仅主机适配器(eth1)
  2. VBox适配器1:NAT(eth0),VBox适配器2:桥接适配器(eth1)

无法运行docker的VirtualBoxconfiguration示例:

  1. VBox适配器1:桥接适配器(eth0)
  2. VBox适配器1:桥接适配器(eth0),VBox适配器2:NAT(eth1)

注意在所有四种情况下,virtualbox ubuntu os可以访问互联网,但是当NAT优先于桥接接口时,docker只能拉取图像。