IPs for all the Things

Thursday, January 28, 2016 ยท 1 min read

This is so cool I can hardly stand it.

In Docker 1.10, the awesome libnetwork team added the ability to specify a specific IP for a container. If you want to see the pull request it’s here: docker/docker#19001.

I have a IP Block on OVH for my server with 16 extra public IPs. I totally use these for good and not for evil.

But to use these previously with Docker containers meant hackery with the awesome pipework. Or even worse some homegrown, Jess bash scripts.

But now MY LIFE JUST GOT SO MUCH EASIER. Let me show you how:

# create a new bridge network with your subnet and gateway for your ip block
$ docker network create --subnet --gateway iptastic

# run a nginx container with a specific ip in that block
$ docker run --rm -it --net iptastic --ip nginx

# curl the ip from any other place (assuming this is a public ip block duh)
$ curl

# BOOM golden

It’s so amazing I can rewrite tupperwarewithspears to use this :D