Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

doctl

> 开发工具
Open source

The official command line interface for the DigitalOcean API.

3.4K stars0 likes1 views
WebsiteGitHub

About

The official command line interface for the DigitalOcean API.

doctl

…

See the full reference documentation for information about each available command.

  • Installing doctl
    • Using a Package Manager (Preferred)
      • MacOS
      • Snap supported OS
        • Use with kubectl
        • Using doctl compute ssh
        • Use with Docker
      • Arch Linux
      • Fedora
      • Nix supported OS
    • Docker Hub
    • Downloading a Release from GitHub
    • Installing Beta Releases
    • Building with Docker
    • Building the Development Version from Source
    • Dependencies
  • Authenticating with DigitalOcean
    • Logging into multiple DigitalOcean accounts
  • Configuring Default Values
    • Environment Variables
  • Enabling Shell Auto-Completion
    • Linux Auto Completion
    • MacOS
  • Uninstalling doctl
    • Using a Package Manager
      • MacOS Uninstall
  • Examples
  • Tutorials

Installing doctl

Using a Package Manager (Preferred)

A package manager allows you to install and keep up with new doctl versions using only a few commands. Our community distributes doctl via a growing set of package managers in addition to the officially supported set listed below; chances are good a solution exists for your platform.

MacOS

Use Homebrew to install doctl on macOS:

bash
brew install doctl

doctl is also available via MacPorts. Note that the port is community maintained and may not be on the latest version.

Snap supported OS

Use Snap on Snap-supported systems to install doctl:

bash
sudo snap install doctl
Use with kubectl

Using kubectl requires the kube-config personal-files connection for doctl:

bash
sudo snap connect doctl:kube-config
Using doctl compute ssh

Using doctl compute ssh requires the core ssh-keys interface:

bash
sudo snap connect doctl:ssh-keys :ssh-keys
Use with Docker

Using doctl registry login requires the dot-docker personal-files connection for doctl:

bash
sudo snap connect doctl:dot-docker

This allows doctl to add DigitalOcean container registry credentials to your Docker configuration file.

Arch Linux

doctl is available in the official Arch Linux repository:

bash
sudo pacman -S doctl

Fedora

doctl is available in the official Fedora repository:

bash
sudo dnf install doctl

Nix supported OS

Users of NixOS or other supported platforms may install doctl from Nixpkgs. Please note this package is also community maintained and may not be on the latest version.

Docker Hub

Containers for each release are available under the digitalocean organization on Docker Hub. Links to the containers are available in the GitHub releases.

Downloading a Release from GitHub

Visit the Releases page for the doctl GitHub project, and find the appropriate archive for your operating system and architecture. Download the archive from your browser or copy its URL and retrieve it to your home directory with wget or curl.

For example, with wget:

bash
cd ~
wget https://github.com/digitalocean/doctl/releases/download/v<version>/doctl-<version>-linux-amd64.tar.gz

Or with curl:

bash
cd ~
curl -OL https://github.com/digitalocean/doctl/releases/download/v<version>/doctl-<version>-linux-amd64.tar.gz

Extract the binary:

tar xf ~/doctl-<version>-linux-amd64.tar.gz

Or download and extract with this oneliner:

bash
curl -sL https://github.com/digitalocean/doctl/releases/download/v<version>/doctl-<version>-linux-amd64.tar.gz | tar -xzv

where <version> is the full semantic version, e.g., 1.17.0.

On Windows systems, you should be able to double-click the zip archive to extract the doctl executable.

Move the doctl binary to somewhere in your path. For example, on GNU/Linux and OS X systems:

bash
sudo mv ~/doctl /usr/local/bin

Windows users can follow How to: Add Tool Locations to the PATH Environment Variable in order to add doctl to their PATH.

Installing Beta Releases

New features are sometimes shipped in beta releases ahead of a general availability (GA) release so they can be tried out early. Beta releases are tagged vX.Y.Z-beta.N and published on the Releases page, marked as "Pre-release".

Note: The package managers above (Homebrew, Snap, dnf) install the latest GA release only — they do not include beta/preview features. To use a preview feature, install the beta build with one of the methods below. This is expected behavior, not a bug.

Install a beta with go install (quickest)

If you have a Go environment configured, the fastest way is to install a specific beta tag directly. Check the Releases page for the latest -beta tag and use it in place of v<version>-beta.<n>:

go install github.com/digitalocean/doctl/cmd/doctl@v<version>-beta.<n>

This drops the doctl binary in $(go env GOPATH)/bin; make sure that directory is on your PATH.

Build a beta from source

With a configured Go environment, build directly from the beta tag (or a feature branch):

bash
git clone https://github.com/digitalocean/doctl.git
cd doctl
git checkout v<version>-beta.<n>
go build -o doctl ./cmd/doctl
sudo mv ./doctl /usr/local/bin

Download a prebuilt beta from GitHub (no Go required)

If you don't have a Go environment, open the Releases page, choose the latest -beta release, and download the archive for your platform. For example, on GNU/Linux:

bash
curl -sL https://github.com/digitalocean/doctl/releases/download/v<version>-beta.<n>/doctl-<version>-beta.<n>-linux-amd64.tar.gz | tar -xzv
sudo mv ./doctl /usr/local/bin

If the asset filename pattern differs, copy the exact download URL from the release page rather than guessing it.

Verify the installed version

doctl version

The reported version should match the -beta tag you installed. Beta builds may contain features that are still changing and are generally less stable than GA releases.

Example

For instance, to install the v1.163.0-beta.2 tag with go install:

go install github.com/digitalocean/doctl/cmd/[email protected]
doctl version
# doctl version 1.163.0-beta.2-...

Building with Docker

If you have Docker configured, you can build a local Docker image using doctl's Dockerfile and run doctl within a container.

bash
docker build --tag=doctl .

Then you can run it within a container.

bash
docker run --rm --interactive --tty --env=DIGITALOCEAN_ACCESS_TOKEN="your_DO_token" doctl any_doctl_command

Building the Development Version from Source

If you have a Go environment configured, you can install the development version of doctl from the command line.

go install github.com/digitalocean/doctl/cmd/doctl@latest

While the development version is a good way to take a peek at doctl's latest features before they get released, be aware that it may have bugs. Officially released versions will generally be more stable.

Dependencies

doctl uses Go modules with vendoring.

Authenticating with DigitalOcean

To use doctl, you need to authenticate with DigitalOcean by providing an access token, which can be created from the Applications & API section of the Control Panel. You can learn how to generate a token by following the DigitalOcean API guide.

Docker users will have to use the DIGITALOCEAN_ACCESS_TOKEN environmental variable to authenticate, as explained in the Installation section of this document.

If you're not using Docker to run doctl, authenticate with the auth init command.

doctl auth init

You will be prompted to enter the DigitalOcean access token that you generated in the DigitalOcean control panel.

DigitalOcean access token: your_DO_token

After entering your token, you will receive confirmation that the credentials were accepted. If the token doesn't validate, make sure you copied and pasted it correctly.

Validating token: OK

This will create the necessary directory structure and configuration file to store your credentials.

Logging into multiple DigitalOcean accounts

doctl allows you to log in to multiple DigitalOcean accounts at the same time and easily switch between them with the use of authentication contexts.

By default, a context named default is used. To create a new context, run doctl auth init --context <new-context-name>. You may also pass the new context's name using the DIGITALOCEAN_CONTEXT environment variable. You will be prompted for your API access token which will be associated with the new context.

To use a non-default context, pass the context name to any doctl command. For example:

doctl compute droplet list --context <new-context-name>

To set a new default context, run doctl auth switch --context <new-context-name>. This command will save the current context to the config file and use it for all commands by default if a context is not specified.

The --access-token flag or DIGITALOCEAN_ACCESS_TOKEN environment variable are acknowledged only if the default context is used. Otherwise, they will have no effect on what API access token is used. To temporarily override the access token if a different context is set as default, use doctl --context default --access-token your_DO_token ....

Configuring Default Values

The doctl configuration file is used to store your API Access Token as well as the defaults for command flags. If you find yourself using certain flags frequently, you can change their default values to avoid typing them every time. This can be useful when, for example, you want to change the username or port used for SSH.

On OS X, doctl saves its configuration as ${HOME}/Library/Application Support/doctl/config.yaml. The ${HOME}/Library/Application Support/doctl/ directory will be created once you run `doctl

Issues· 170 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gocloudcommand-linedigitaloceanhacktoberfest

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具