When and how does digitalocean set a droplet's hostname?

Posted December 8, 2015 3.8k views

One of the clever things that digitalocean does is to set the hostname of a new droplet to a sensible value. When, and how, does this happen?

I have a third-party daemon (newrelic-sysmond) that needs to know the hostname. When it starts, the hostname still is packer-... and not the hostname set by the digitalocean droplet initiating process. In the /etc/rc structure, the hostname is set in rcS.d/, which should occur before rc2.d/S01newrelic-sysmond. However, it seems the hostname still has the name at image-creation time by the time rc2.d/S01newrelic-sysmond is run.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

The hostname is set based on the name given the droplet. This is done (to the best of my knowledge) via cloud-init on the first boot. You should be able to review this process by looking at /var/log/cloud-init.log and /var/log/cloud-init-output.log

  • Thanks, I see, a lot of debugging info but it is clear the hostname is set at an earlier stage.

    On Debian cloud-init-local is run at order 01 from rc2.d, just like newrelic-sysmond—but still, cloud-init-local should be earlier because of lexicographic ordering. Or can init scripts be run in parallel?