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.
-
Set NetworkManager to use dnsmasq by adding the following under the
[main]
block of /etc/NetworkManager/NetworkManager.conf
dns=dnsmasq