在ubuntu virtualbox中安装Docker,无法拉出镜像



我在windows 10上的virtualbox 5.0.26上安装了ubuntu 14.04.5作为客户操作系统。我不知道ubuntu安装有什么问题,它似乎运行得很好,有一个桥接的互联网连接,所以得到了自己的ip。

我已经按照docker docs for linux的说明安装了docker。安装正常,没有任何错误,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-world测试时,守护进程挂起
root@ubuntu-z9:~# docker run hello-world
Unable to find image 'hello-world:latest' locally

有一个超时

我可以在主机windows 10机器上运行docker-machine而没有任何问题,所以我认为问题在于我在virtualbox和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>nn" 
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>nn" 
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>nn"

对诊断或解决问题的方法有什么建议吗?

许多谢谢。

这是一个简单的问题,毫无疑问记录在某个地方,但我错过了它。我把答案贴在这里,以防别人也有同样的问题。

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

VirtualBox配置示例运行docker:

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

VirtualBox配置示例不工作运行docker:

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

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

最新更新