Accessing host machine as localhost from a Docker container that's also inside a boot2docker vm
Thanks to palimpestor's answer I figured it out:
Instead of --net="host"
, use --add-host="localhost:10.0.2.2"
Indeed:
- 10.0.2.2 is the default gateway defined for the guest network interface in NAT mode (reference).
Read: it's your host, seen from boot2docker. --add-host...
is addinglocalhost 10.0.2.2
in /etc/hosts (reference)
Note: you need to have set up a NAT adapter in your boot2docker VM VirtualBox settings (I did it through the GUI, don't know the CLI).
Instead of running with --net="host"
, try --add-host="localhost:192.168.59.3"
, which is the boot2docker host IP.