Skip to content

Instantly share code, notes, and snippets.

@iamatypeofwalrus
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamatypeofwalrus/73df15929c9b4eb5f9e9 to your computer and use it in GitHub Desktop.
Save iamatypeofwalrus/73df15929c9b4eb5f9e9 to your computer and use it in GitHub Desktop.
localdocker: It's like localhost for your boot2docker ip address

Why?

Having to remeber what the boot2docker ip address sucks, wouldn't it be better to access it like localhost?

You can!

First you need to get the boot2docker ip address. You can get that in terminal:

$ boot2docker ip

On my computer I get:

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

So I'll add 192.168.59.103 to /private/etc/hosts

$ sudo vim /private/etc/hosts

My hosts file looks like this now:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0 localhost
192.168.59.103 localdocker

Save it!

In use

Some browsers (ahem Chrome ahem) won't play nicely if you don't prepend an http:// or https:// to localdocker. So if you have a docker image running on :80 like I do then you can hit up http://localdocker:80 in your browsee, or you can curl the image with curl localdocker.

Caveats

The boot2docker ip address is not guaranteed to be static. It may change! You can just update the hosts file when that happens. Having said that, my ip has been static since I've been using this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment