Skip to content

Instantly share code, notes, and snippets.

View rmarins's full-sized avatar

Rafael Marins rmarins

View GitHub Profile
@awood
awood / README.md
Last active August 29, 2015 13:56
Auto-resolving your Docker containers

For development, I run Docker containers that start up running sshd. Then I ssh to those machines and do my development work. It works great but finding the host name to ssh into was always a chore. It usually involved something like docker inspect my_container | grep IPAddress and then copying the address. Very tedious. I'd rather just type ssh root@my_container. So I did some searching and came up with a solution similar to http://blog.oddbit.com/2013/10/04/automatic-dns-entries-for-libvirt-domains/

What we will do is have incrond create a hosts file every time a container is started or stopped. Then we will set NetworkManager to use dnsmasq and resolve names through that hosts file.

The below instructions work on Fedora 20. For other distributions, you're on your own, but the principles should be the same.

  1. Set NetworkManager to use dnsmasq by adding the following under the [main] block of /etc/NetworkManager/NetworkManager.conf

dns=dnsmasq