Skip to content
The official command line interface for the DigitalOcean API.
Go Shell Other
Branch: master
Clone or download
Latest commit a719bb9 Oct 11, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/doctl remove unused docs directory and scripts Jul 30, 2019
commands consolidate defaultContext into args Oct 10, 2019
do adds test for projects resources assignment Oct 8, 2019
doc/adr use architecture decision records Aug 2, 2019
dockerfiles Bump godo, add note about updating snap image Sep 23, 2019
integration adds --trace flag test to projects delete Oct 11, 2019
pkg remove obsolete windows ssh code Oct 2, 2019
pluginhost projects support Oct 16, 2018
scripts install gh-changelog-generator in temp dir to protect go.mod Oct 1, 2019
snap adopt os.UserConfigDir to locate user config dir Sep 23, 2019
vendor bumps spec to latest version Oct 11, 2019
.gitignore optimize building snap via custom docker image Sep 13, 2019
.goreleaser.yml release to dockerhub Jul 29, 2019
.travis.yml install gh-changelog-generator in temp dir to protect go.mod Oct 1, 2019 retire CHANGELOG, streamline release process Aug 1, 2019 update TOC in CONTRIBUTING Aug 29, 2019
Dockerfile remove hardcoded version from Dockerfile Jul 23, 2019 Upgrade to Go 1.13 Sep 23, 2019
Dockerfile.cntr adopt os.UserConfigDir to locate user config dir Sep 23, 2019
Dockerfile.goreleaser fix doctl compute ssh in docker hub container Aug 1, 2019
LICENSE.txt updating license to apache 2 Dec 14, 2015
Makefile removes mistakenly added focus Oct 10, 2019 update README: config file location and dependencies Oct 11, 2019
args.go consolidate defaultContext into args Oct 10, 2019
args_short.go projects support Oct 16, 2018
doit.go consolidate live and test flag semantics Oct 4, 2019
doit_test.go projects support Oct 16, 2018
errors.go remove extracted error and make more informative Sep 23, 2019
errors_test.go remove extracted error and make more informative Sep 23, 2019
go.mod bumps spec to latest version Oct 11, 2019
go.sum bumps spec to latest version Oct 11, 2019
recorder.go projects support Oct 16, 2018
sammy.txt create an installer for doit Dec 14, 2015
util.go projects support Oct 16, 2018
util_test.go projects support Oct 16, 2018

doctl Build Status GoDoc Go Report Card

doctl is a command line interface for the DigitalOcean API.

  doctl [command]

Available Commands:
  account     account commands
  auth        auth commands
  completion  completion commands
  compute     compute commands
  databases   database commands
  help        Help about any command
  kubernetes  kubernetes commands
  projects    projects commands
  version     show the current version

  -t, --access-token string   API V2 Access Token
  -u, --api-url string        Override default API V2 endpoint
  -c, --config string         config file (default is $HOME/.config/doctl/config.yaml)
      --context string        authentication context name
  -h, --help                  help for doctl
  -o, --output string         output format [text|json] (default "text")
      --trace                 trace api access
  -v, --verbose               verbose output

Use "doctl [command] --help" for more information about a command.

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.


Use Homebrew to install doctl on macOS:

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:

sudo snap install doctl
Use with kubectl

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

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

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

sudo snap connect doctl:ssh-keys :ssh-keys

Arch Linux

Arch users not using a package manager can install from the AUR.

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 from your browser or copy its URL and retrieve it to your home directory with wget or curl.

For example, with wget:

cd ~

Or with curl:

cd ~
curl -OL<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:

curl -sL<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:

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.

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.

docker build --tag=doctl .

Then you can run it within a container.

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 get

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.


doctl uses Go modules with vendoring.

Authenticating with DigitalOcean

In order 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 in to 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 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 as described above to any doctl command. To set a new default context, run doctl auth switch. 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 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.

doctl's configuration file can be found at os.UserConfigDir().

The configuration file is automatically created and populated with default properties when you authenticated with doctl for the first time. The typical format for a property is category.command.sub-command.flag: value. For example, the property for the force flag with tag deletion is tag.delete.force.

To change the default SSH user used when connecting to a Droplet with doctl, look for the compute.ssh.ssh-user property and change the value after the colon. In this example, we changed it to the username sammy.

. . .
compute.ssh.ssh-user: sammy
. . .

Save and close the file. The next time you use doctl, the new default values you set will be in effect. In this example, that means that it will SSH as the sammy user (instead of the default root user) next time you log into a Droplet.

Enabling Shell Auto-Completion

doctl also has auto-completion support. It can be set up so that if you partially type a command and then press TAB, the rest of the command is automatically filled in. For example, if you type doctl comp<TAB><TAB> drop<TAB><TAB> with auto-completion enabled, you'll see doctl compute droplet appear on your command prompt.

Note: Shell auto-completion is not available for Windows users.

How you enable auto-completion depends on which operating system you're using. If you installed doctl via Homebrew, auto-completion is activated automatically, though you may need to configure your local environment to enable it.

doctl can generate an auto-completion script with the doctl completion your_shell_here command. Valid arguments for the shell are Bash (bash) and ZSH (zsh). By default, the script will be printed to the command line output. For more usage examples for the completion command, use doctl completion --help.


The most common way to use the completion command is by adding a line to your local profile configuration. At the end of your ~/.profile file, add this line:

source <(doctl completion your_shell_here)

Then refresh your profile.

source ~/.profile


macOS users will have to install the bash-completion framework to use the auto-completion feature.

brew install bash-completion

After it's installed, load bash_completion by adding following line to your .profile or .bashrc/.zshrc file.

source $(brew --prefix)/etc/bash_completion

Then refresh your profile using the appropriate command for bash configurations file.

source ~/.profile
source ~/.bashrc
source ~/.zshrc


doctl is able to interact with all of your DigitalOcean resources. Below are a few common usage examples. To learn more about the features available, see the full tutorial on the DigitalOcean community site.

  • List all Droplets on your account:
doctl compute droplet list
  • Create a Droplet:
doctl compute droplet create <name> --region <region-slug> --image <image-slug> --size <size-slug>
  • Assign a Floating IP to a Droplet:
doctl compute floating-ip-action assign <ip-addr> <droplet-id>
  • Create a new A record for an existing domain:
doctl compute domain records create --record-type A --record-name www --record-data <ip-addr> <domain-name>

doctl also simplifies actions without an API endpoint. For instance, it allows you to SSH to your Droplet by name:

doctl compute ssh <droplet-name>

By default, it assumes you are using the root user. If you want to SSH as a specific user, you can do that as well:

doctl compute ssh <user>@<droplet-name>


You can’t perform that action at this time.