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

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.