doctl-compute-droplet
Manage DigitalOcean Droplets (Virtual Machines)
TLDR
Create a droplet
Delete a droplet
List droplets
SYNOPSIS
doctl compute droplet action [arguments...] [flags...]
Common actions include:
create name --image image-slug --size size-slug --region region-slug [flags...]
list [flags...]
get droplet-id [flags...]
delete droplet-id [flags...]
actions action-type droplet-id [flags...]
PARAMETERS
create action parameters
Parameters for creating a new Droplet.
--name <name>: The desired name for the new Droplet.
--image <image-slug|image-id>: The operating system image or snapshot ID to use (e.g., 'ubuntu-20-04-x64').
--size <size-slug>: The Droplet size (e.g., 's-1vcpu-1gb').
--region <region-slug>: The datacenter region where the Droplet will be created (e.g., 'nyc1').
--ssh-keys <fingerprint|id,...>: Comma-separated list of SSH key fingerprints or IDs to add.
--user-data <path|string>: Path to a file or string containing user data (cloud-init) for customization.
--vpc-uuid <uuid>: UUID of the VPC network to assign the Droplet to.
list action parameters
Parameters for listing existing Droplets.
--format <columns>: Comma-separated list of columns to display (e.g., 'ID,Name,PublicIPv4,Status').
--no-header: Suppress the table header in output.
--output <json|yaml|text>: Specify the output format.
get action parameters
Parameters for retrieving detailed information about a single Droplet.
<droplet-id>: The numeric ID of the Droplet to inspect.
--format <columns>: Similar to list, specifies columns for output.
delete action parameters
Parameters for deleting one or more Droplets.
<droplet-id|droplet-name>: The ID(s) or name(s) of the Droplet(s) to delete.
--force: Skip the interactive confirmation prompt.
actions action parameters
Parameters for performing specific operations on a Droplet.
<action-type>: The type of action to perform (e.g., 'power_on', 'reboot', 'snapshot', 'resize', 'rebuild').
<droplet-id>: The ID of the Droplet to apply the action to.
--image <image-slug|image-id>: (Specific to 'rebuild' action) The new image for rebuilding.
--size <size-slug>: (Specific to 'resize' action) The new size slug for the Droplet.
--name <snapshot-name>: (Specific to 'snapshot' action) Name for the new snapshot.
DESCRIPTION
The doctl compute droplet command is a crucial part of the DigitalOcean command-line client (doctl) used for comprehensive management of DigitalOcean Droplets. Droplets are scalable Linux-based virtual machines offered by DigitalOcean. This subcommand allows users to perform a wide array of operations including creating new Droplets, listing existing ones, retrieving detailed information about a specific Droplet, deleting Droplets, and executing various Droplet-specific actions like powering them on/off, rebooting, resizing, rebuilding, taking snapshots, and managing their associated backups, floating IPs, and firewall rules. It provides a programmatic interface to interact with the DigitalOcean Droplet API, enabling automation and scripting of infrastructure management tasks.
CAVEATS
API Rate Limits: DigitalOcean API has rate limits. Frequent requests might lead to temporary blocking.
Permissions: Ensure your DigitalOcean API token has the necessary read/write permissions for Droplet management.
Cost Implications: Creating, resizing, or enabling features for Droplets will incur costs. Always verify actions.
Asynchronous Operations: Many Droplet actions (like create, resize, snapshot) are asynchronous. The command might return before the action is fully completed.
Data Loss: Deleting a Droplet is permanent and results in data loss. Always back up critical data.
AUTHENTICATION
doctl requires authentication via a DigitalOcean API token. This is typically configured using doctl auth init or by setting the DIGITALOCEAN_ACCESS_TOKEN environment variable.
OUTPUT FORMATTING FOR SCRIPTING
doctl commands, including compute droplet, offer flexible output options using --format, --output json, or --output yaml which are excellent for scripting and integration with other tools.
INTERACTIVE PROMPTS AND FORCE FLAG
Many destructive operations (e.g., delete) include interactive prompts for confirmation. These can be bypassed for automation using the --force flag.
HISTORY
The doctl command-line interface was developed by DigitalOcean to provide a powerful, user-friendly, and scriptable way to interact with their cloud platform. It has evolved significantly since its initial release, adding support for new DigitalOcean products and features, and improving command syntax and output. The compute droplet subcommand has been a core component from early versions, reflecting the Droplet's central role in the DigitalOcean ecosystem, continuously updated to support new Droplet capabilities like VPC networking, SSH key management, and user data integration.
SEE ALSO
doctl compute volume(1), doctl compute snapshot(1), doctl compute firewall(1), doctl auth(1), doctl account(1)