64

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
5
  • 1
    I am having this issue as well today. I updated vbox recently, wonder if they are related.
    – darethas
    Commented Nov 5, 2014 at 4:15
  • I've even tried re-installing it without any success.
    – nikhil
    Commented Nov 7, 2014 at 5:10
  • For boot2docker on Windows, see stackoverflow.com/a/29303930/6309
    – VonC
    Commented Mar 27, 2015 at 15:09
  • hi again, just curious, where you running cisco anyconnect at the time you experienced this?
    – darethas
    Commented Jun 15, 2015 at 14:45
  • @treehau5 Hi, I had cisco anyconnect installed when I experienced this but I wasn't connected to VPN.
    – nikhil
    Commented Jun 15, 2015 at 15:41

12 Answers 12

64

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
4
  • 1
    I ran into this on Mavericks - the culprit is Cisco Anyconnect. Docker was working fine at work, then got home and everything broke. Commented Jan 22, 2015 at 4:34
  • Yes! This worked for me! I had everything running beautifully until I needed to connect to my work's VPN using anyconnect and then it stopped responding. I'm on OSX Yosemite.
    – neurosnap
    Commented Jan 25, 2015 at 23:28
  • I don't have a clue why this worked, but it did. After doing a clean install of boot2docker for the first time, I was getting dial tcp: lookup index.docker.io: connection refused when running docker run hello-world. I don't have Cisco AnyConnect or any other weird VPN setups - just OSX 10.10.3.
    – Andrew
    Commented May 7, 2015 at 6:19
  • Thanks this was the one that fixed it for me on Yosemite 10.10.3 Commented Jun 24, 2015 at 20:59
57

I have had this issue as well and here is a temporary solution.

First, open VirtualBox and check the network settings on the boot2docker VM to see what the host only adapter is named. In my case, it's vboxnet1; for you, it may be vboxnet0.

Then, apply this command:

sudo route -nv add -net 192.168.59 -interface vboxnet1

Now you should be able to run Docker commands.

See this issue for more information.

I am noticing over time that a common denominator in this problem is Cisco anyconnect (me included), for what it's worth.

6
  • Should I run this command in docker or my iTerm shell? Either would return me a error. Commented Nov 15, 2014 at 4:26
  • @kxxoling I ran it just fine in item2. What is the error?
    – darethas
    Commented Nov 19, 2014 at 23:02
  • @treehau5 finally, I Found I'm Right at first , what's wrong is the docker image exported from my workmate. Commented Nov 20, 2014 at 1:57
  • 2
    FYI, docker was working fine for me until my laptop went to sleep. Then I ran into this problem for which this answer solves. Commented Dec 26, 2014 at 18:14
  • Followed the provided link and found a solution that worked for me: github.com/boot2docker/boot2docker/issues/…
    – vhs
    Commented Mar 18, 2015 at 6:06
45

Here's what I did to fix the issue (I use OS X v10.10 (Yosemite) and the accepted answer didn't work for me):

  • boot2docker delete - Warning: this deletes all your Docker images.
  • In VirtualBox, go to VirtualBox (menu) → Preferences → Network → Host Only Networks
    • Delete the host only networks, and then I re-added them
  • boot2docker init
  • boot2docker up

Now Docker works from the OS X command line via iTerm2 for me.

4
  • 5
    This only works if you turn off anyconnect, and also we might want to add a warning about this deleting all your images. Theres a fix for the second part here: github.com/boot2docker/boot2docker/issues/…
    – cbron
    Commented Dec 8, 2014 at 19:54
  • 1
    This worked for me, but I didn't need to delete my host only networks. Commented Jul 14, 2015 at 18:28
  • 1
    As @cbron said - this only works if you turn off Cisco AnyConnect
    – kellyfj
    Commented Sep 16, 2015 at 19:39
  • This is the only solution that worked for me, i don't use any Cisco stuff but i had 4 Vagrant VMs in VirtualBox at the same time. Commented Oct 8, 2015 at 14:20
6

This happened to me as well, and none of the previous answers fixed the problem.

Today, thanks to a colleague's suggestion, I did not startup my VPN connection first. I rebooted my machine, and started with Docker from the beginning.

boot2docker init
boot2docker up
$(boot2docker shellinit)
docker run hello-world

It worked as expected!

I found this post by Florian Rosenberg useful. I read through it in detail, but I think most of what he is suggesting in the first part has been factored into the most recent version of boot2docker. But the insightful bit was "Connecting to VPN Things will break".

It suggested to look for a firewall rule that denies any to any. So, without VPN fired up I looked for this rule, and it was not there. Sure enough, once I fired up my VPN, I got the following (different) error...

docker run hello-world
2014/11/13 11:11:18 Post https://192.168.59.103:2376/v1.15/containers/create: dial tcp 192.168.59.103:2376: permission denied

I checked the firewall rules, and sure enough a new rule was added...

sudo ipfw -a list | grep "deny ip"
00411    1      64 deny ip from any to any 

Once I removed that firewall rule with:

sudo ipfw delete 00411

I was able to talk to Docker from the OS X command shell.

1
  • This could also help someone who faces this issue. +1
    – nikhil
    Commented Nov 13, 2014 at 19:32
5

OK, so this happened to me as well.

First of all, setting the environment variables is necessary. But then, I kept getting the I/O timeout error even after that.

So, instead of starting boot2docker by running the application package (clicking on the boot2docker icon), I started it from the command line.

I first executed,

$boot2docker init

This said, the VM was already running.

Then I went ahead and tried to start it.

$boot2docker start

This started it.

You can verify it by running

$boot2docker info

It prints a JSON about your running instance.

Then, you can ssh into it and run

$boot2docker ssh
$docker run hello-world

That's it.

0
4

I had this issue after running Cisco AnyConnect. Even after I shut down AnyConnect, the issue persisted.

@treehau5's answer works, but doing boot2docker poweroff, and then using Activity Monitor, kill the ciscod left behind by AnyConnect also worked for me. Then I opened a new Terminal window and started boot2docker normally and Docker commands then worked fine.

2
  • There is a daeon running: '/opt/cisco/anyconnect/bin/vpnagentd -execv_instance' that automatically starts back up even if i kill -9 it.... any clue how to stop that deamon. Is it through launctl? Commented Dec 12, 2014 at 6:14
  • The user name is no longer "treehau5". Can you add a direct link to the referenced answer (either by user "darethas", "Ashish Juyal", or "wlan0".). Commented Dec 25, 2019 at 0:24
3

It was easy for me. I upgraded VirtualBox and this problem went away.

1
  • Worked for my case too.
    – pfac
    Commented Feb 28, 2015 at 13:46
2

I tried treehau5's method, but it did not work. I changed VirtualBox's Network setting of boot2docker VM setting - 'host-only Adapter's Promiscuous mode to 'Allow All'.

1
  • The user name is no longer "treehau5". Which answer is referred to? Commented Dec 25, 2019 at 0:34
0

Here's what worked for me when I hit a similar snag. Make sure you've upgraded VirtualBox, then:

  1. boot2docker stop
  2. boot2docker init
  3. boot2docker start; eval "$(boot2docker shellinit)"

Then, just for sanity's sake, check that $DOCKER_HOST matches $(boot2docker ip). I suspect I had many things going on, as when I first started, $DOCKER_HOST had become unset somehow.

The issue and some discussion can be found in the GitHub issues page here - it does rather seem as if it's often just a case of VirtualBox being flaky.

0

I removed vboxnet0 from VirtualBox preferences and initialized a second boot2docker VM (boot2docker --vm="boot2docker-vm2" init) to recreate vboxnet0 with the correct settings.

After this, things seemed to be back to normal.

-1

In my case I just had to restart my Mac host machine and the problem was gone! I was not connected to VPN or anything of that sort. I am not sure of the reason why this happened.

-1

Check your DOCKER_HOST environment variable. It should be pointing to:

export DOCKER_HOST=tcp://192.168.59.103:2376
4
  • Yes, it's set up correctly. The docker command is picking that up correctly as you can see from the output of the command. Do you have any other suggestions?
    – nikhil
    Commented Nov 2, 2014 at 3:27
  • you can try restarting your boot2docker. Commented Nov 2, 2014 at 7:14
  • Tried that too a couple of times, no luck still.
    – nikhil
    Commented Nov 3, 2014 at 2:07
  • the vboxVM gets a new ip each time you boot it. It is in the range 192.168.0.0/16. You cant always export DOCKER_HOST=tcp://192.168.59.103:2376
    – wlan0
    Commented Apr 15, 2015 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.