简体   繁体   English

在virtualbox的ubuntu上安装docker,无法拉取映像

[英]docker installation on ubuntu in virtualbox, cannot pull images

I have ubuntu 14.04.5 installed as guest os in virtualbox 5.0.26 running on windows 10. I am not aware of any issues with the ubuntu installation, it seems to run fine and has a bridged internet connection so gets its own ip. 我在Windows 10上运行的virtualbox 5.0.26中以访客操作系统的形式安装了ubuntu 14.04.5,我不知道ubuntu安装是否存在任何问题,它似乎运行良好并且具有桥接互联网连接,因此拥有自己的ip。

I have installed docker following the directions on docker docs for linux . 我已经按照docker docs for linux上的说明安装了docker。 The installation goes fine without any errors and the docker daemon starts ok. 安装正常,没有任何错误,并且docker守护程序正常启动。 Here is the docker info: 这是码头工人信息:

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

The machine can see the internet fine and access hub.docker.com from a browser. 机器可以正常上网并从浏览器访问hub.docker.com。

However, when I run the simple hello-world test the daemon hangs 但是,当我运行简单的hello-world测试时,守护进程挂起

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

with a timeout. 超时。

I can run docker-machine without any issues on the host windows 10 machine so I believe the issue lies in my setup of the ubuntu machine in virtualbox and docker. 我可以在Windows 10主机上运行docker-machine而没有任何问题,因此我认为问题出在我在virtualbox和docker中设置ubuntu机器上。

Here is the logging output of the docker daemon on the ubuntu guest machine: 这是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"

Any suggestions on a way forward to diagnose or fix the issue? 关于诊断或解决问题的方法有什么建议吗?

Many thanks. 非常感谢。

It was a simple issue, undoubtedly documented somewhere but I missed it. 这是一个简单的问题,毫无疑问地记录在某处,但我错过了。 I post an answer here in case someone else has the same. 如果其他人也有相同的问题,我会在这里发布答案。

The virtualbox os (ubuntu in my case) has to have a NAT network adapter and the NAT adapter has to have higher priority than a bridge adapter (if you have one). virtualbox os(在我的情况下为ubuntu)必须具有NAT网络适配器,并且NAT适配器的优先级必须高于网桥适配器(如果有的话)。 You don't need a bridged adapter to run docker (but if you want the virtualbox to have an ip on your local network then you do need to add a bridged adapter.) 您不需要桥接适配器来运行docker(但是,如果您希望virtualbox在本地网络上具有ip,那么您确实需要添加桥接适配器。)

VirtualBox configuration examples that work to run docker: VirtualBox的配置实例的工作运行泊坞窗:

  1. VBox Adapter 1: NAT (eth0), VBox Adapter 2: Host-only Adapter (eth1) VBox适配器1:NAT(eth0),VBox适配器2:仅主机适配器(eth1)
  2. VBox Adapter 1: NAT (eth0), VBox Adapter 2: Bridged Adapter (eth1) VBox适配器1:NAT(eth0),VBox适配器2:桥接适配器(eth1)

VirtualBox configuration examples that do not work to run docker: 无法运行docker的VirtualBox配置示例:

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

Note in all four cases the virtualbox ubuntu os has access to the internet but docker can only pull images when NAT has priority over the bridged interface. 请注意,在所有四种情况下,virtualbox ubuntu os都可以访问互联网,但是docker仅在NAT优先于桥接接口时才能拉映像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM