3458f0f068
This change makes it clear that we are really after the fqdn and not the hostname. The code has been working only because Digital Ocean sets the hostname to be the FQDN. What I learnt about hostnames ----------------------------- The kernel has get/sethostname() and get/setdomainname() system calls. There is restriction on what can be set as the hostname. init scripts usually set the contents of /etc/hostname. How hostname is setup depends on the distribution - it could be the simple name OR the fqdn. CentOS for example puts the FQDN and ubuntu puts the simple name. DigitalOcean puts the name of the box in /etc/hostname. So far this has worked in our favor because os.hostname() which uses gethostname() gave us the FQDN. Docker sets only the simple name in /etc/hostname but sets up the OS host/domain name correctly. This mean os.hostname() does not provide the FQDN in docker. Altering it is not possible because it requires the the SYS_ADMIN caps which container don't have (unless --priveliged). Also, hostname -f first does gethostname(), then does a DNS lookup using getaddrinfo() or the deprecated getaddressbyname(). Using that IP, it does a reverse lookup. The DNS system itself using nsswitch.conf to determine look up order. The first entry in /etc/hosts file is taken as the domain entry for reverse lookups.