← 返回命令列表

Linux command

doctl 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Authenticate with

doctl auth init

List all droplets

doctl compute droplet list

Create a droplet

doctl compute droplet create [name] --size [s-1vcpu-1gb] --image [ubuntu-22-04-x64] --region [nyc1]

Delete a droplet

doctl compute droplet delete [droplet_id]

List Kubernetes clusters

doctl kubernetes cluster list

Get kubeconfig

doctl kubernetes cluster kubeconfig save [cluster_name]

List available regions

doctl compute region list

List all databases

doctl databases list

List Spaces

doctl spaces list

Create a container registry

doctl registry create [name]

List SSH keys

doctl compute ssh-key list

Output as JSON

doctl compute droplet list --output json

说明

doctl is the official command-line interface for DigitalOcean, providing access to all DigitalOcean services including Droplets, Kubernetes, App Platform, Databases, and more. The tool enables infrastructure automation, CI/CD integration, and scriptable management of DigitalOcean resources. It supports multiple authentication contexts for managing different accounts or teams. doctl mirrors the DigitalOcean API functionality, allowing complete control over cloud resources from the command line without using the web console.

参数

auth init
Authenticate with API token.
auth list
List available authentication contexts.
compute droplet _ACTION_
Manage Droplets (create, list, delete, get, etc.).
compute volume _ACTION_
Manage block storage volumes.
compute domain _ACTION_
Manage DNS domains and records.
compute firewall _ACTION_
Manage cloud firewalls.
compute load-balancer _ACTION_
Manage load balancers.
kubernetes cluster _ACTION_
Manage Kubernetes clusters.
apps _ACTION_
Manage App Platform applications.
databases _ACTION_
Manage managed database clusters.
spaces _ACTION_
Manage Spaces object storage.
registry _ACTION_
Manage container registries.
serverless _ACTION_
Manage serverless functions.
monitoring _ACTION_
Manage monitoring alert policies and uptime checks.
projects _ACTION_
Organize and assign resources to projects.
--access-token _TOKEN_
DigitalOcean API token. Overrides config and DIGITALOCEAN_ACCESS_TOKEN.
--output _FORMAT_
Output format: text, json.
--format _COLUMNS_
Comma-separated list of columns to display in table output.
--context _NAME_
Use named authentication context.
--trace
Show a log of network activity while performing a command.
--verbose
Enable verbose output.
--help
Display help information.

FAQ

What is the doctl command used for?

doctl is the official command-line interface for DigitalOcean, providing access to all DigitalOcean services including Droplets, Kubernetes, App Platform, Databases, and more. The tool enables infrastructure automation, CI/CD integration, and scriptable management of DigitalOcean resources. It supports multiple authentication contexts for managing different accounts or teams. doctl mirrors the DigitalOcean API functionality, allowing complete control over cloud resources from the command line without using the web console.

How do I run a basic doctl example?

Run `doctl auth init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does auth init do in doctl?

Authenticate with API token.