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. The windows host is not behind a proxy.

I have installed docker following the directions on docker docs for linux. The installation goes fine without any errors and the docker daemon starts ok. 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 ubuntu vm can see the internet fine and can access hub.docker.com from a browser.

However, when I run the simple hello-world test the daemon hangs

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.

Here is the logging output from the daemon on the ubuntu guest when I run it in debug mode:

$ docker run 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.
(This is a total newbie question so I also posted it on stackoverflow.)

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). 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.)

VirtualBox configuration examples that work to run docker:

  1. VBox Adapter 1: NAT (eth0)
  2. VBox Adapter 1: NAT (eth0), VBox Adapter 2: Bridged Adapter (eth1)

VirtualBox configuration examples that do not work to run docker:

  1. VBox Adapter 1: Bridged Adapter (eth0)
  2. VBox Adapter 1: Bridged Adapter (eth0), VBox Adapter 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.

Not just the Docker image, is any software downloadble from the Ubuntu?
Seems to be a networking issue. What is the Network Adapter setting? Should be “NAT”.

Hello!

I am facing problem in running docker on Ubuntu VM (16.04 LTS) .When I run

docker run hello-world

it says

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See ‘docker run --help’.

Unable to figure out the issue. Can you help please ?