DigitalOcean Droplets are Linux-based virtual machines (VMs) that run on top of virtualized hardware. Each Droplet you create is a new server you can use, either standalone or as part of a larger, cloud-based infrastructure.
Metadata is a DigitalOcean service that allows a Droplet to access data about itself.
Droplets can access the metadata service using the special, static, link-local IP address 169.254.169.254
. This allows you to use the same commands on different Droplets without needing to change the destination IP address.
You can query the metadata API from a Droplet by sending an HTTP GET request to a metadata endpoint. For example, this curl
command sends an HTTP GET request to the top level of a Droplet’s metadata endpoint, /metadata/v1/
:
curl http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address
This returns an index of the available Droplet metadata:
id
hostname
user-data
vendor-data
public-keys
region
interfaces/
dns/
floating_ip/
tags/
You can think of this index like a directory listing. Items in the index without a trailing slash represent data, and items with a trailing slash are nested indexes. You can further curl
into the indexes to see more entries.
For example, you can retrieve the Droplet’s public IPv4 address:
curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address
Full documentation of the metadata service and its endpoints are available in the Droplet metadata API reference.