Outbound connections from Docker with VirtualBox not working?

Using Docker and VirtualBox and having trouble making outbound connections? For instance, you might be getting errors like:

curl: (7) Failed connect to; No route to host


Error: Redis connection to redis:6379 failed - connect EHOSTUNREACH

Here’s what I did to fix it. First I ssh’d into the Docker machine:

$ docker-machine ssh dev

And took a look at the network config:

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 08:00:27:C8:C7:50
inet addr:  Bcast:  Mask:
inet6 addr: fe80::a00:27ff:fec8:c750/64 Scope:Link
RX packets:230796 errors:0 dropped:0 overruns:0 frame:0
TX packets:62400 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:238029328 (227.0 MiB)  TX bytes:4768029 (4.5 MiB)

Where I see eth0 is configured on this subnet and doesn’t seem to be modifiable. So I fixed this via:

$ docker-machine stop dev
$ VBoxManage modifyvm dev --natnet1 ""
$ docker-machine restart dev

And boom, just like that it works:

$ docker@dev:~$ curl
HTTP/1.1 200 OK

Follow me on Twitter to keep up with what I’ve learned building my personal finance tool, Stash.

Read more posts …
Written: November 17th, 2015
Categories: docker, virtualbox