In my previous blog entry, I mentioned that Docker didn’t provide any way to add host-to-ip mappings to /etc/hosts. Well, the most recent version of Docker (1.3.1) now addresses that issue with a new add hosts option. Let’s take a quick look at what it does. Given a standard default /etc/hosts. % docker run -it ubuntu cat /etc/hosts 172.17.0.8 b14031841b2b 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters We can add a mapping for server ‘foo’ at ‘10.
Update: Read my newer post that talks about Docker’s add-host option. Did you know that Docker doesn’t let you (easily) modify /etc/hosts? You can’t programmatically add aliases for localhost or new hostname-to-ip mappings. In short, Docker treats /etc/hosts like a static resource. No problem. This will just take a quick Unix script to solve. Attempt 1, the slate is wiped clean No big deal, right? We simply write ourselves a little sed script to alias localhost and add a couple additional hostname mappings.
Update: Source code is available on github. I’ve put the first release of hsparklines up on Hackage. It’s a sparklines library implemented in Haskell. I know there are a number of web service based solutions that one could use for this, but for those who’ve used web services, you know that there are some things you want to keep local. If you haven’t played with sparklines yet, you should. They’re minigraphs inspired by Edward Tufte to present a large amount of contextual information in a minimum of space.