The official command line interface for the DigitalOcean API.
The official command line interface for the DigitalOcean API.
…See the full reference documentation for information about each available command.
doctl
doctl
doctlA 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 doctldoctl is also available via MacPorts. Note that
the port is community maintained and may not be on the latest version.
Use Snap on Snap-supported systems to
install doctl:
sudo snap install doctlkubectlUsing kubectl requires the kube-config personal-files connection for doctl:
sudo snap connect doctl:kube-configdoctl compute sshUsing doctl compute ssh requires the core ssh-keys interface:
sudo snap connect doctl:ssh-keys :ssh-keysUsing doctl registry login requires the dot-docker personal-files connection for doctl:
sudo snap connect doctl:dot-dockerThis allows doctl to add DigitalOcean container registry credentials to your Docker configuration file.
doctl is available in the official Arch Linux repository:
sudo pacman -S doctldoctl is available in the official Fedora repository:
sudo dnf install doctlUsers 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.
Containers for each release are available under the digitalocean
organization on Docker Hub.
Links to the containers are available in the GitHub releases.
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:
cd ~
wget https://github.com/digitalocean/doctl/releases/download/v<version>/doctl-<version>-linux-amd64.tar.gzOr with curl:
cd ~
curl -OL https://github.com/digitalocean/doctl/releases/download/v<version>/doctl-<version>-linux-amd64.tar.gzExtract the binary:
tar xf ~/doctl-<version>-linux-amd64.tar.gzOr download and extract with this oneliner:
curl -sL https://github.com/digitalocean/doctl/releases/download/v<version>/doctl-<version>-linux-amd64.tar.gz | tar -xzvwhere <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/binWindows users can follow How to: Add Tool Locations to the PATH Environment Variable in order to add doctl to their PATH.
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.
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.
With a configured Go environment, build directly from the beta tag (or a feature branch):
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/binIf 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:
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/binIf the asset filename pattern differs, copy the exact download URL from the release page rather than guessing it.
doctl versionThe 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.
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-...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_commandIf 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@latestWhile 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.
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 initYou will be prompted to enter the DigitalOcean access token that you generated in the DigitalOcean control panel.
DigitalOcean access token: your_DO_tokenAfter 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: OKThis will create the necessary directory structure and configuration file to store your credentials.
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 ....
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
No open issues yet, or sync has not completed.