DigitalOcean
CLI Production Surface

doctl account get

doctl reference for engineers with production scars. Honest about what belongs in the console or Terraform.

24 entries
7 phases
doctl v1.x
What's not here, and why. doctl functions: immature CLI surface, use the console. doctl registry builds. Use Docker buildx + crane. Droplet provisioning belongs in Terraform. doctl monitoring alert mutations: Terraform. App Platform deploys via git push, not doctl.
cross-cutting: know these before anything else
auth + context
doctl auth init doctl auth init --context prod doctl auth switch --context prod doctl auth list doctl account get
--format + --no-header
doctl compute droplet list --format ID,Name,Status,PublicIPv4 doctl compute droplet list --format ID,Name --no-header doctl compute droplet list --output json | jq '.[].name' # --no-header + --format for xargs pipelines
regions + sizes
doctl compute region list doctl compute size list --format Slug,Memory,VCPUs,PriceMonthly doctl compute image list --public --format Slug,Distribution,Name | grep ubuntu # always pin image slug, not "latest"
Phase 24 shown
ServicePhaseKey commandsUse case
doctl auth auth
doctl auth init --context prod doctl auth init --context staging doctl auth switch --context prod doctl auth list doctl account get # token stored in ~/.config/doctl/config.yaml # use DIGITALOCEAN_ACCESS_TOKEN env var in CI
Named contexts switch between accounts or teams: production vs staging tokens in the same config. In CI, always use DIGITALOCEAN_ACCESS_TOKEN env var; never commit tokens to config files. Token scopes are set at creation time on the DO control panel. Use read-only tokens for audit scripts.
droplet list / inspect droplets
doctl compute droplet list --format ID,Name,Status,PublicIPv4,Region,Size doctl compute droplet get <id> doctl compute droplet list --tag-name env:prod --format ID,Name,PublicIPv4 doctl compute droplet neighbors <id> doctl compute droplet backups list <id>
--tag-name filters by tag: the correct way to target a fleet of droplets rather than hardcoding IDs. neighbors lists droplets on the same physical host: useful before taking a snapshot (avoids co-located droplet I/O contention). Tags are applied at creation; doing this in Terraform keeps them consistent.
droplet actions droplets
doctl compute droplet-action power-off --droplet-id <id> --wait doctl compute droplet-action power-on --droplet-id <id> --wait doctl compute droplet-action reboot --droplet-id <id> --wait doctl compute droplet-action snapshot --droplet-id <id> --snapshot-name myapp-$(date +%Y%m%d) --wait doctl compute droplet-action resize --droplet-id <id> --size s-4vcpu-8gb --resize-disk=false --wait
--wait blocks until the action completes: essential in scripts where the next step depends on the action finishing. resize --resize-disk=false allows resizing back down later (disk resizes are permanent). Always snapshot before a resize or risky operation. Power-off before snapshot ensures filesystem consistency.
droplet SSH + console droplets
doctl compute ssh <id> doctl compute ssh <id> --ssh-user deploy --ssh-port 2222 doctl compute ssh <id> --ssh-command "df -h && free -m" doctl compute droplet list --format ID,Name --no-header | fzf | awk '{print $1}' | xargs doctl compute ssh
doctl compute ssh looks up the droplet's IP and uses your local SSH key: no IP lookup needed. The fzf pipeline is a practical interactive picker for fleets. --ssh-command runs a one-off command without an interactive session: useful for quick diagnostics across multiple droplets via a loop.
snapshots droplets
doctl compute snapshot list --resource-type droplet --format ID,Name,ResourceId,CreatedAt,Size doctl compute snapshot get <id> doctl compute snapshot delete <id> doctl compute snapshot list --resource-type droplet --format CreatedAt,ID --no-header | sort | head -5 # snapshots billed at $0.06/GB/month: audit regularly
Snapshots accumulate silently. Sort by date and pipe the oldest IDs to delete in a cleanup script. DigitalOcean charges per GB for snapshot storage: a fleet of droplets with weekly snapshots and no retention policy becomes expensive. Build a retention script: keep last N, delete the rest.
DOKS clusters kubernetes
doctl kubernetes cluster list --format ID,Name,Region,Version,Status,NodePools doctl kubernetes cluster kubeconfig save my-cluster doctl kubernetes cluster kubeconfig save my-cluster --expiry-seconds 3600 doctl kubernetes cluster get-upgrades my-cluster doctl kubernetes cluster upgrade my-cluster --version 1.30.2-do.0
kubeconfig save merges credentials into your local kubeconfig. --expiry-seconds generates a short-lived token. Use in CI to avoid long-lived cluster credentials in pipeline secrets. get-upgrades lists available Kubernetes versions before scheduling a maintenance window. Always check patch versions, not just minors.
DOKS node pools kubernetes
doctl kubernetes cluster node-pool list my-cluster --format ID,Name,Size,Count,MinNodes,MaxNodes,AutoScale doctl kubernetes cluster node-pool update my-cluster <pool-id> --count 5 doctl kubernetes cluster node-pool update my-cluster <pool-id> --auto-scale --min-nodes=2 --max-nodes=10 doctl kubernetes cluster node-pool delete-node my-cluster <pool-id> <node-id> --skip-drain=false
Manual node pool scaling overrides autoscale. Use for planned capacity changes. delete-node --skip-drain=false cordons and drains before deletion. Always set this explicitly. Autoscale min/max bounds prevent runaway scaling during a traffic event or misconfigured HPA.
Spaces (object storage) storage
doctl compute cdn list # Spaces uses S3-compatible API. Use s3cmd or aws cli: aws s3 ls s3://myspace --endpoint-url https://nyc3.digitaloceanspaces.com aws s3 sync ./dist s3://myspace/assets --endpoint-url https://nyc3.digitaloceanspaces.com --acl public-read aws s3 presign s3://myspace/file.tar.gz --endpoint-url https://nyc3.digitaloceanspaces.com --expires-in 3600 # configure: AWS_ACCESS_KEY_ID=spaces-key AWS_SECRET_ACCESS_KEY=spaces-secret
Spaces has no native doctl subcommand for object operations. Use the S3-compatible API with the AWS CLI or s3cmd, pointing --endpoint-url at your region's endpoint. Spaces access keys are separate from DO API tokens: generate them in the console under API → Spaces Keys.
volumes (block storage) storage
doctl compute volume list --format ID,Name,Size,Region,DropletIDs doctl compute volume-action attach <volume-id> <droplet-id> --wait doctl compute volume-action detach <volume-id> <droplet-id> --wait doctl compute volume snapshot <volume-id> --snapshot-name vol-snap-$(date +%Y%m%d) doctl compute volume delete <id>
Volumes with no DropletIDs are unattached and still billing. Audit regularly. Detach before delete: deleting an attached volume is blocked. Snapshot a volume before resizing or migrating its droplet. Attach/detach require the droplet to be powered on.
firewalls networking
doctl compute firewall list --format ID,Name,Status,InboundRules,OutboundRules,DropletIDs,Tags doctl compute firewall get <id> doctl compute firewall add-rules <id> --inbound-rules "protocol:tcp,ports:443,sources:addresses:0.0.0.0/0" doctl compute firewall remove-rules <id> --inbound-rules "protocol:tcp,ports:22,sources:addresses:0.0.0.0/0" doctl compute firewall add-droplets <firewall-id> --droplet-ids <id>
DO firewalls are stateful and applied at the network edge, not the droplet. A droplet with no firewall applied is fully exposed. add-rules and remove-rules modify an existing firewall in-place: all attached droplets are affected immediately. Prefer tag-based assignment over droplet ID lists for maintainability.
load balancers networking
doctl compute load-balancer list --format ID,Name,Status,IP,Algorithm,DropletIDs doctl compute load-balancer get <id> doctl compute load-balancer add-droplets <lb-id> --droplet-ids <id> doctl compute load-balancer remove-droplets <lb-id> --droplet-ids <id> doctl compute load-balancer get <id> --format HealthCheck
Health check config is shown in get output: the first place to look when traffic isn't reaching droplets. Adding/removing droplets takes effect immediately without recreating the LB. The DO LB does not support SSL termination with self-signed certs: Let's Encrypt integration is managed through the console or Terraform.
domains / DNS networking
doctl compute domain list doctl compute domain records list example.com --format ID,Type,Name,Data,TTL doctl compute domain records create example.com --record-type A --record-name api --record-data 10.0.0.1 --record-ttl 300 doctl compute domain records update example.com --record-id <id> --record-data 10.0.0.2 doctl compute domain records delete example.com --record-id <id>
DO DNS is free and manageable via CLI: useful for simple setups. update takes a record ID, not the record name: list first to get the ID. TTL of 300 is reasonable for records that might change; use 3600+ for stable records. For complex DNS needs (weighted routing, health checks) use Route53 or Cloudflare instead.
VPC networking
doctl vpcs list --format ID,Name,Region,IPRange,Default doctl vpcs get <id> doctl vpcs list-members <id> --format URN,Name,ResourceType
list-members shows all resources (droplets, DBs, LBs, Kubernetes clusters) inside a VPC: the fastest inventory query for a network segment. Every region has a default VPC; new resources go into the default unless explicitly assigned. VPC peering is not supported. Use a private network design within a single region.
managed databases databases
doctl databases list --format ID,Name,Engine,Version,Status,Region,NumNodes doctl databases get <id> --format Connection doctl databases connection <id> --format Host,Port,User,Password,Database,URI doctl databases pool list <id> doctl databases replica list <id> doctl databases backups list <id> doctl databases resize <id> --num-nodes 3 --size db-s-2vcpu-4gb
doctl databases connection returns the full connection URI: pipe to a password manager or secret store rather than printing to a terminal. Connection pool list shows pgBouncer pool configs. Replica list confirms standby replicas exist before a planned failover. Resize requires a maintenance window. Check the console for impact.
DB firewall rules databases
doctl databases firewalls list <db-id> doctl databases firewalls append <db-id> --rule droplet:<droplet-id> doctl databases firewalls append <db-id> --rule k8s:<cluster-uuid> doctl databases firewalls append <db-id> --rule ip_addr:10.0.0.0/8 doctl databases firewalls remove <db-id> --uuid <rule-uuid>
DO managed databases are private by default: no access without an explicit firewall rule. Allowlisting by droplet ID or Kubernetes cluster UUID is safer than CIDR ranges. After removing a droplet from the firewall, connections are dropped immediately: useful for incident isolation.
App Platform apps
doctl apps list --format ID,Spec.Name,DefaultIngress,ActiveDeployment.Phase doctl apps get <id> doctl apps get-deployment <app-id> <deploy-id> doctl apps list-deployments <id> --format ID,Phase,UpdatedAt doctl apps create-deployment <id> --force-rebuild doctl apps logs <id> --type=run --follow
create-deployment --force-rebuild triggers a full rebuild and deploy without a git push: useful when rebuilding to pick up a new base image or dependency. logs --type=run --follow tails runtime logs; use --type=build for build logs. ActiveDeployment.Phase in list output shows whether the app is ACTIVE, DEPLOYING, or ERROR.
Container Registry apps
doctl registry get doctl registry login doctl registry repository list-v2 --format Name,LatestTag,LatestManifest.UpdatedAt doctl registry repository list-tags <repo> --format Tag,ManifestDigest,UpdatedAt doctl registry repository delete-manifest <repo> <digest> doctl registry garbage-collection start --include-untagged-manifests
registry login configures Docker credentials for the DO registry. garbage-collection start --include-untagged-manifests reclaims storage from deleted/untagged images, without running GC, deleted manifest storage is not freed. Run GC after bulk manifest deletes. Registry storage is billed; audit with repository list-v2 regularly.
No entries match this filter.