Skip to content

DigitalOcean CLI (doctl)

Comprehensive DigitalOcean CLI commands and workflows for managing droplets, load balancers, databases, and Kubernetes clusters.

Installation & Authentication

CommandDescription
doctl auth initInitialize authentication
doctl auth listList authentication contexts
doctl auth switch --context CONTEXT_NAMESwitch authentication context
doctl account getGet account information
doctl balance getGet account balance

Droplets (Virtual Machines)

Droplet Management

CommandDescription
doctl compute droplet listList all droplets
doctl compute droplet create mydroplet --size s-1vcpu-1gb --image ubuntu-20-04-x64 --region nyc1Create droplet
doctl compute droplet delete DROPLET_IDDelete droplet
doctl compute droplet get DROPLET_IDGet droplet details
doctl compute droplet reboot DROPLET_IDReboot droplet
doctl compute droplet power-off DROPLET_IDPower off droplet
doctl compute droplet power-on DROPLET_IDPower on droplet
doctl compute droplet shutdown DROPLET_IDShutdown droplet

Droplet Actions

CommandDescription
doctl compute droplet-action list DROPLET_IDList droplet actions
doctl compute droplet-action resize DROPLET_ID --size s-2vcpu-2gbResize droplet
doctl compute droplet-action snapshot DROPLET_ID --snapshot-name my-snapshotCreate snapshot
doctl compute droplet-action restore DROPLET_ID --image IMAGE_IDRestore from image
doctl compute droplet-action rebuild DROPLET_ID --image ubuntu-20-04-x64Rebuild droplet

SSH and Access

CommandDescription
doctl compute ssh DROPLET_NAMESSH into droplet
doctl compute ssh DROPLET_NAME --ssh-user rootSSH with specific user
doctl compute ssh-key listList SSH keys
doctl compute ssh-key create --name mykey --public-key-file ~/.ssh/id_rsa.pubAdd SSH key
doctl compute ssh-key delete KEY_IDDelete SSH key

Images and Snapshots

CommandDescription
doctl compute image listList all images
doctl compute image list --publicList public images
doctl compute image list-userList user images
doctl compute image get IMAGE_IDGet image details
doctl compute image delete IMAGE_IDDelete image
doctl compute image update IMAGE_ID --name new-nameUpdate image name

Volumes (Block Storage)

CommandDescription
doctl compute volume listList all volumes
doctl compute volume create myvolume --size 100GiB --region nyc1Create volume
doctl compute volume delete VOLUME_IDDelete volume
doctl compute volume attach VOLUME_ID DROPLET_IDAttach volume to droplet
doctl compute volume detach VOLUME_IDDetach volume
doctl compute volume snapshot VOLUME_ID --snapshot-name my-volume-snapshotCreate volume snapshot

Load Balancers

CommandDescription
doctl compute load-balancer listList load balancers
doctl compute load-balancer create --name mylb --forwarding-rules entry_protocol:http,entry_port:80,target_protocol:http,target_port:80 --region nyc1Create load balancer
doctl compute load-balancer delete LB_IDDelete load balancer
doctl compute load-balancer add-droplets LB_ID --droplet-ids DROPLET_ID1,DROPLET_ID2Add droplets to LB
doctl compute load-balancer remove-droplets LB_ID --droplet-ids DROPLET_ID1Remove droplets from LB

Networking

Firewalls

CommandDescription
doctl compute firewall listList firewalls
doctl compute firewall create --name myfirewall --inbound-rules protocol:tcp,ports:22,sources:0.0.0.0/0Create firewall
doctl compute firewall delete FIREWALL_IDDelete firewall
doctl compute firewall add-droplets FIREWALL_ID --droplet-ids DROPLET_IDAdd droplets to firewall
doctl compute firewall remove-droplets FIREWALL_ID --droplet-ids DROPLET_IDRemove droplets from firewall

VPC Networks

CommandDescription
doctl vpcs listList VPCs
doctl vpcs create --name myvpc --region nyc1Create VPC
doctl vpcs delete VPC_IDDelete VPC
doctl vpcs get VPC_IDGet VPC details

Floating IPs

CommandDescription
doctl compute floating-ip listList floating IPs
doctl compute floating-ip create --region nyc1Create floating IP
doctl compute floating-ip delete FLOATING_IPDelete floating IP
doctl compute floating-ip-action assign FLOATING_IP DROPLET_IDAssign floating IP
doctl compute floating-ip-action unassign FLOATING_IPUnassign floating IP

Kubernetes (DOKS)

Cluster Management

CommandDescription
doctl kubernetes cluster listList Kubernetes clusters
doctl kubernetes cluster create mycluster --region nyc1 --node-pool "name=worker-pool;size=s-2vcpu-2gb;count=3"Create cluster
doctl kubernetes cluster delete CLUSTER_IDDelete cluster
doctl kubernetes cluster get CLUSTER_IDGet cluster details
doctl kubernetes cluster kubeconfig save CLUSTER_IDSave kubeconfig

Node Pools

CommandDescription
doctl kubernetes cluster node-pool list CLUSTER_IDList node pools
doctl kubernetes cluster node-pool create CLUSTER_ID --name new-pool --size s-2vcpu-2gb --count 2Create node pool
doctl kubernetes cluster node-pool delete CLUSTER_ID POOL_IDDelete node pool
doctl kubernetes cluster node-pool resize CLUSTER_ID POOL_ID --count 5Resize node pool

Databases

Database Clusters

CommandDescription
doctl databases listList database clusters
doctl databases create mydb --engine mysql --size db-s-1vcpu-1gb --region nyc1Create database cluster
doctl databases delete DATABASE_IDDelete database cluster
doctl databases get DATABASE_IDGet database details
doctl databases resize DATABASE_ID --size db-s-2vcpu-2gbResize database

Database Operations

CommandDescription
doctl databases db list DATABASE_IDList databases
doctl databases db create DATABASE_ID --name myappCreate database
doctl databases db delete DATABASE_ID myappDelete database
doctl databases user list DATABASE_IDList database users
doctl databases user create DATABASE_ID --username myuserCreate database user

Database Backups

CommandDescription
doctl databases backups list DATABASE_IDList backups
doctl databases backups restore DATABASE_ID BACKUP_IDRestore from backup

Spaces (Object Storage)

CommandDescription
doctl compute cdn listList CDN endpoints
doctl compute cdn create --origin spaces.example.com --domain cdn.example.comCreate CDN endpoint
doctl compute cdn delete CDN_IDDelete CDN endpoint

Apps Platform

App Management

CommandDescription
doctl apps listList apps
doctl apps create --spec app.yamlCreate app from spec
doctl apps get APP_IDGet app details
doctl apps delete APP_IDDelete app
doctl apps update APP_ID --spec app.yamlUpdate app

App Deployments

CommandDescription
doctl apps list-deployments APP_IDList deployments
doctl apps get-deployment APP_ID DEPLOYMENT_IDGet deployment details
doctl apps logs APP_ID --type buildGet build logs
doctl apps logs APP_ID --type runGet runtime logs

Monitoring

Alerts

CommandDescription
doctl monitoring alert listList alert policies
doctl monitoring alert create --spec alert.yamlCreate alert policy
doctl monitoring alert delete ALERT_IDDelete alert policy
doctl monitoring alert get ALERT_IDGet alert details

Projects

CommandDescription
doctl projects listList projects
doctl projects create --name myproject --description "My project"Create project
doctl projects get PROJECT_IDGet project details
doctl projects update PROJECT_ID --name "New name"Update project
doctl projects resources list PROJECT_IDList project resources

Regions and Sizes

CommandDescription
doctl compute region listList available regions
doctl compute size listList available droplet sizes
doctl kubernetes options regionsList Kubernetes regions
doctl kubernetes options versionsList Kubernetes versions
doctl databases options enginesList database engines
doctl databases options sizesList database sizes