Docker can't connect to boot2docker because of TCP timeout

nikhil picture nikhil · Nov 1, 2014 · Viewed 39.7k times · Source

I'm running Mac OS 10.9.5 (Mavericks), I've followed https://docs.docker.com/installation/mac/ to install Docker. I get a timeout error message when I run Docker even though the boot2docker VM is running in the background.

nikhil@macbook ~> boot2docker status
running
nikhil@macbook ~> boot2docker ip

The VM's Host only interface IP address is: 192.168.59.103

nikhil@macbook ~> docker run hello-world
2014/11/01 01:01:31 Post https://192.168.59.103:2376/v1.15/containers/create: dial tcp 192.168.59.103:2376: i/o timeout
nikhil@macbook ~> docker search ubuntu
2014/11/01 01:02:40 Get https://192.168.59.103:2376/v1.15/images/search?term=ubuntu: dial tcp 192.168.59.103:2376: i/o timeout

I have verified that Docker is running inside the boot2docker VM and that my port is correct.

nikhil@macbook ~> boot2docker ssh
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.3.1, build master : 9a31a68 - Fri Oct 31 03:14:34 UTC 2014
Docker version 1.3.1, build 4e9bbfa
docker@boot2docker:~$ sudo netstat -ntpl | grep docker
tcp        0      0 :::2376                 :::*                    LISTEN      629/docker

Answer

user2472759 picture user2472759 · Jan 6, 2015

I am using OS X v10.10 (Yosemite) and Cisco Anyconnect (which are apparently a bad combination for using boot2docker), and the following finally worked for me (thanks to the linked GitHub issue comment):

These steps will add a port forwarding rule and modify your environment to have Docker point to 127.0.0.1 (instead of 192.168.59.103 or other NATed IP address).

First - boot2docker needs to be installed, but not running.

If it is currently running - stop it now:

boot2docker down

Add a rule to forward traffic from 127.0.0.1:2376 to port 2376 on the boot2docker vm:

vboxmanage modifyvm "boot2docker-vm" --natpf1 "docker,tcp,127.0.0.1,2376,,2376"

Start boot2docker:

boot2docker up

Set default DOCKER environment variables:

$(boot2docker shellinit)

Override the DOCKER_HOST variable to point to 127.0.0.1:

export DOCKER_HOST=tcp://127.0.0.1:2376

Now you should be able to run docker commands:

docker version