如何使用Doctl--DigitalOcean官方命令行客户端

此教程的早期版本是由 Brennen Bearnes编写的。

介绍

DigitalOcean 的基于 Web 的控制面板提供了点击接口来管理 Droplets. 但是,如果您有许多 Droplets 来管理,需要从终端管理 Droplets 没有可用的图形桌面,或者您有可以从可编写接口中受益的任务,您可能会选择命令行工具。

doctl是官方的DigitalOcean命令行客户端,它使用DigitalOcean API(https://developers.digitalocean.com/)提供访问大多数帐户和Droplet功能。

前提条件

要遵循本教程,您将需要:

本教程旨在作为大多数doctl操作的参考。由于doctl命令与API密切并行,所以阅读 API文档How To Use the DigitalOcean API v2也可能有用。

通用doctl的使用

召唤命令

doctl中,通过给实用程序一个命令、一个或多个子命令以及有时一个或多个指定特定值的选项来调用单个特征。

*「帳戶」為帳戶相關資訊 *「auth」為與DigitalOcean 認證 *「計算」為管理基礎設施

要查看所有命令的概述,您可以自行调用doctl。 要查看三个主要类别中的所有可用命令,您可以使用doctl类别,例如doctl compute

在 JSON 格式中获取数据

在脚本环境中,或者使用数据处理工具在命令行上工作时,从命令中获取可机器阅读的输出往往是有用的。

默认情况下,doctl 将其输出格式化为可人读的文本列,但可以使用 --output json 选项生成详细的 JSON 输出。

1doctl compute droplet get droplet_id --output json
 1[secondary_label Sample Output]
 2{
 3  "id": droplet_id,
 4  "name": "droplet_name",
 5  "memory": 1024,
 6  "vcpus": 1,
 7  "disk": 30,
 8  "region": {
 9    "slug": "nyc3",
10    "name": "New York 3",
11    "sizes": [
12...

除了在大多数编程语言的标准库中可读的格式之外,JSON输出还可能允许对Dropplets和其他资源进行更精细的检查。

形式化

通常只从输出中获取一组字段是有用的。 要做到这一点,您可以使用 - 格式标志,然后列出所需的字段列表。 例如,如果您只想要获取您的 Droplets 的 ID、名称和 IP 地址,则可以使用以下命令:

1doctl compute droplet list --format "ID,Name,PublicIPv4"
1[secondary_label Sample output]
2ID Name Public IPv4
350513569 doctl-1 67.205.152.65
450513570 test 67.205.148.128
550513571 node-1 67.205.131.88

寺庙

「doctl compute droplet get」命令支持输出模板,允许您定制输出格式。

例如,如果您想要在droplet_name: droplet_name格式中获取Droplet的名称,则可以使用以下get命令:

1doctl compute droplet get 12345678 --template "droplet_name: {{ .Name}}
1[secondary_label Output]
2droplet_name: ubuntu-1gb-nyc3-01

与资源合作

资源列表

要获取资源列表,例如 Droplets,您可以使用没有参数的列表命令。

1doctl compute droplet list
1[secondary_label Sample output for list command]
2ID Name Public IPv4 Private IPv4 Public IPv6 Memory VCPUs Disk Region Image Status Tags
350513569 test-1 67.205.152.65 512 1 20 nyc1 Ubuntu 16.04.2 x64 active
450513571 test-2 67.205.131.88 512 1 20 nyc1 Ubuntu 16.04.2 x64 active
550513570 site 67.205.148.128 512 1 20 nyc1 Ubuntu 16.04.2 x64 active

列表命令支持一个球作为一个可选的参数。一个球代表一个具有野卡字符的模式,可以用来按名称过滤特定资源。例如,要获取一个名称以测试开头的Dropplets列表,您可以使用以下命令:

1doctl compute droplet list 'test*'
1[secondary_label Sample output for list command with 'doctl-' as glob]
2ID Name Public IPv4 Private IPv4 Public IPv6 Memory VCPUs Disk Region Image Status Tags
350513569 test-1 67.205.152.65 512 1 20 nyc1 Ubuntu 16.04.2 x64 active
450513571 test-2 67.205.131.88 512 1 20 nyc1 Ubuntu 16.04.2 x64 active

创造资源

创建资源需要更长的命令,具有更详细的参数。 要创建 Droplet,您需要指定您想要使用的图像、数据中心区域和使用相关的 Slug 所需的 Droplet 类型。 请参阅 New Size Slugs for Droplet Plan Changes 以查找您想要使用的 Slug。

例如,下列命令会创建一个名为 test的 64 位 Debian 8 Droplet,具有 1 GB 的内存、 1 个 CPU、 SSH 密钥和备份。

1doctl compute droplet create test --size s-1vcpu-1gb	 --image debian-8-x64 --region nyc1 --ssh-keys 4d:23:e6:e4:8c:17:d2:cf:89:47:36:b5:c7:33:40:4e --enable-backups

你会看到这个输出:

1[secondary_label Sample Droplet creation output]
2ID Name Public IPv4 Memory VCPUs Disk Region Image Status
311450164 test 1024 1 30 nyc1 Debian 8.3 x64 new

删除资源需要一个资源 ID 作为一个论点,或一个资源名称,如果某个资源没有一个 ID (例如标签)。

1doctl compute droplet delete 123456
1[secondary_label Output]
2Warning: Are you sure you want to delete droplet(s) (y/N) ?

未提供答案或提供不同于y的答案将取消操作而不删除资源. 您可以让doctl假定答案是肯定的,而不明确提供答案,使用--f(--force)旗帜:

1doctl compute droplet delete -f 123456

寻找资源的唯一标识符

创建 Droplet 命令需要一系列标识符,如 NYC1 区域的 nyc1', Debian 图像的 debian-8-x64',以及一个 SSH 密钥指纹,如 `4d:23:e6:e4:8c:17:d2:cf:89:47:36:b5:c7:33:40:4e。

一些资源,如Droplets和图像,通过DigitalOcean数据库中唯一的值(通常是数字值)来识别。

您可以从 API 获取大多数命令所需的唯一标识符:

CommandNotes
doctl compute droplet listYour Droplets. Some commands also take the name; most require the numeric value from the ID column.
doctl compute ssh-key listThe SSH keys associated with your account. For Droplet creation, you can specify either the numeric ID or fingerprint.
doctl compute region listAvailable regions. Use the string in the Slug column.
doctl compute image listAvailable images, including snapshots, backups, and base distribution images. Use the string in the Slug column for creating new Droplets.
doctl compute size listAvailable Droplet sizes. Use the string in the Slug column.
doctl compute tag listAvailable Tags. Use the string in the Name column.

与Droplets合作

创建,删除和检查滴滴

doctl compute droplet 命令允许您创建、删除和检查 Droplets. 再次,大多数用于使用单个 Droplets 的命令都需要 Droplet 的唯一 ID,这些 ID 可以在doctl droplet list的输出中找到。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --图像图像_slug - 区域 nyc1 ' 创建 Droplet。 大小、 图像和区域都是强制性的 。 _ _ QQ 删除 dropplet_ id_ 或_ name' _ 以 id 或 name 来删除 dropplet 。 _ _ QQ 获取 dropplet_ id' 的细节 。 QQ `内核 dropplet_ id' #Q 列表内核 。 _ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ |

启动滴滴行动

doctl compute droplet-action 命令允许您为 Droplet 启动各种操作,包括电源管理操作和备份和私人网络等转换功能。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 水滴必须用上电源。 通常最好从 Droplet 本身的指令行中做到这一点,以防止数据丢失. _ _ | 'power-on droplet_id' * * Power on a Droplet. Droplet必须停用. _ _+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ image_id' 必须是 Droplet 的备份。 _ ___ 大小 droplet_id- small 2gb' 调整 Droplet 大小 。 水滴必须熄火 默认情况下,磁盘不会被调整大小,这使得Droplet可以被降级. 您可以使用 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 将 Droplet 的内核切换为 内核 id 。 _ _ _ snapshot droplet id- snapshot-name sshort_name' 取下一个 Droplet 的快照, 命名为 snapshot_ name 。 |

与 SSH 合作

建立 SSH 连接

为了通过SSH连接到一个单独的Droplet,通常需要知道其IP地址或完全合格的域名,您可以使用doctl以其名称,数字ID或私人IP连接到Droplet:

1doctl compute ssh droplet_name
1doctl compute ssh droplet_id
1doctl compute ssh --ssh-private-ip droplet_private_ip

此外,您可以使用「--ssh-command」旗帜提供执行命令,此命令将运行,其输出将打印在本地终端上,然后SSH会话将关闭。

1doctl compute ssh --ssh-command command

<$>[注意] 注意:SSH命令转发目前在 Windows 上不可用。

默认 SSH 用户名为 root ( CoreOS 中的core),默认端口为 22. 您可以使用旗帜来设置非默认值并启用其他功能:

FlagDescription
--ssh-user stringUser name to use for the SSH session.
--ssh-port intThe port for the SSH session.
--ssh-key-path stringPath to SSH key.
--ssh-agent-forwardingEnable agent forwarding.

您还可以更改配置文件中的默认配置值。 项目的 README 文件提供了有关如何做到这一点的更多细节。

使用 SSH 密钥

您可以使用doctl compute ssh-key命令来管理与您的帐户相关联的 SSH 公共密钥.大多数指引 SSH 密钥的命令都接受密钥的数字 ID 或其指纹。

doctl compute ssh-key subcommandNotes
listList SSH keys associated with your account.
get ssh_key_id_or_fingerprintGet info on a specific key, by numeric ID or key's fingerprint.
create new_key_name --public-key "public_key"Associate a public key with your account by specifying its contents.
import new_key_name --public-key-file ~/.ssh/id_rsa.pubAssociate a public key with your account by specifying a source file.
delete ssh_key_id_or_fingerprintDelete a key from your account by numeric ID or fingerprint.
update ssh_key_id_or_fingerprint --key-name new_key_nameChange a key's name by numeric ID or fingerprint.

与浮动IPs合作

Floating IP 是一个可公开访问的静态 IP 地址,可以分配给您的 Droplets 之一。 有关该功能的详细描述,请参阅 How To Use Floating IPs on DigitalOcean

doctl compute floating-ip subcommandNotes
listList all Floating IP addresses.
get floating_ip_addressGet the details for a Floating IP address.
create --region nyc1Create a Floating IP in nyc1 region.
delete floating_ip_addressDelete a floating IP address.

将浮动IP分配到Droplets

doctl compute floating-ip-action命令用于从Droplet分配或分配不分配一个浮动IP。

doctl compute floating-ip-action subcommandNotes
assign floating_ip droplet_idAssign a Floating IP to the Droplet by its numeric ID.
unassign floating_ipUnassign a Floating IP.
get floating_ip action_idGet details about a Floating IP action by its numeric ID.

与域名合作

doctl compute domain 命令用于管理域,请参阅我们的 Introduction to Managing DNS series对主题的广泛概述。

doctl compute domain subcommandNotes
listList domains.
create domain_name --ip-address droplet_ip_addressCreate a domain with default records for droplet_ip_address.
get domain_nameGet a domain record.
delete domain_nameDelete a domain.

管理域名记录

doctl 计算域记录命令可用于创建、删除、更新或获取有关域名的 DNS 记录的信息。

doctl compute domain records subcommandNotes
list domain_nameList records for given domain.
create domain_name --record-type record_typeCreate an record for domain.
delete domain_name record_idDelete record by numeric ID.
update domain_name --record-id record_idUpdate record by numeric ID.

使用区块存储量

创建、删除和检查区块存储量

可以使用doctl 计算量命令创建、删除或获取有关 DigitalOcean 区块存储量的信息. 有关此功能的更多信息,请阅读我们的指南 如何在 DigitalOcean 上使用区块存储

doctl compute volume subcommandNotes
listList volumes.
create volume_name --region volume_region --size volume_sizeCreate a volume. The name, region, and size are mandatory.
get volume_IDGet volume by numeric ID.
delete volume_IDDelete volume.
snapshot volume_IDSnapshot volume.

启动量化行动

doctl calculate volume-action 命令允许您启动一个卷的操作,包括将卷附加到和从Droplets中分离。

doctl compute volume-action subcommandNotes
attach volume_id droplet_idAttach a volume to a Droplet.
detach volume_id droplet_idDetach a volume from a Droplet.
resize volume_id --region volume_region --size new_sizeResize a volume.

使用负荷平衡器

doctl计算负载平衡器命令可用于创建、删除或获取有关DigitalOcean的负载平衡器的信息. 有关此功能的更多信息,请阅读我们的 Introduction to DigitalOcean Load Balancers

'doctl 计算负载-平衡'子命令 \ 注 ___________ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 区域 lb_区域 --tag-name 标记_name --forwarding-rules 转发_rule" QQ 创建负载平衡器 。 Droplet ID的名称,区域,标签或列表,以及至少一条转发规则是强制性的. _ ___ 更新 - 名称 lb_ 名称 -- 区域 lb_区域 --tag-name 标记_name --forwarding-rules 转发_rule" QQ 创建负载平衡器 。 Droplet ID的名称,区域,标签或列表,以及至少一条转发规则是强制性的. _ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ID QQ 在负载平衡器中添加 Dropplets 。 _ _ remove-dropplet lb_ID - dropplet-ids dropplet_ 从负载平衡器取出滴子。 _ ____++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ QQ QQ移动-前进规则 lb_ID-前进规则-转发-规则' 从负载平衡器中删除转发规则. |

当用作doctl的参数时,应将转发规则表示为:entry_protocol:protocol,entry_port:port,target_protocol:protocol,target_port:port

管理证书

doctl计算证书子命令允许您上传和管理SSL证书、私钥和证书链。

doctl compute certificate subcommandNotes
listList all Certificates.
get certificate_idGet a Certificate by ID.
create --name certificate_name --leaf-certificate-path leaf_certificate_pathCreate a Certificate. Name and Leaf Certificate Path are mandatory.
delete certificate_idDelete a Certificate by ID.

使用 Snapshots 工作

doctl calculate snapshot 命令可用于列出、删除或获取有关 Droplet 和 Volume Snapshots 的信息。

doctl compute snapshot subcommandNotes
listList all Snapshots.
get snapshot_IDGet a Snapshot.
delete snapshot_IDDelete a Snapshot.

要创建一个新的快照,您需要使用相关资源命令树下的相应命令。

  • doctl compute droplet-action snapshot droplet_ID 创建一个从 Droplet 创建的 Snapshot.
  • doctl compute volume snapshot volume_ID 创建了一个从 Volume 创建的 Snapshot.

与图像合作

doctl计算图像命令允许您管理所有图像,包括分发图像,应用图像和用户创建的图像,如备份和快照。我们建议使用快照命令来管理快照,因为它提供了更多细节,具有删除功能,并支持区块存储快照。

doctl compute image subcommandNotes
list --publicList all images.
list-distribution --publicList all available distribution images.
list-application --publicList all available One-Click Applications.
list-userList all user-created images.
get image_idGet an Image by ID.
update image_id --name image_nameUpdate Image's name. Name is mandatory.
delete image_idDelete an Image by ID.

呼吁图像行动

doctl计算图像行动命令允许您传输图像并获取有关图像上召唤的操作的详细信息。

doctl compute image-action subcommandNotes
get image_id --action-id action_idGet an Action for Image by its ID. Action ID is mandatory.
transfer image_id --region regionTransfer an Image to the another region. Image ID and region are mandatory.

与防火墙合作

doctl计算防火墙命令允许您创建和管理防火墙,包括创建和维护规则. 有关使用doctl管理防火墙的更多信息,请参阅如何使用Doctl保护Web服务器基础设施的DigitalOcean云防火墙(https://andsky.com/tech/tutorials/how-to-secure-web-server-infrastructure-with-digitalocean-cloud-firewalls-using-doctl)教程。

================================================================================================================ (============================================================================================= -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --入围规则入围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围规则出围. 名称和至少入境或出境规则是强制性的。 _ _ 更新防火墙' id -- 名称防火墙_ 名称 ——入门规则入门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门 更新防火墙出门规则出门规则出门规则出门规则出门规则出门. 数字标识、名称和至少入境或出境规则是强制性的。 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ________________________________________________________________________________________________ - droplet-ids droplet_IDs" 将 Droplets 以数字化的ID添加到防火墙上。 _ remove-droplets frearl_id - drotlet-ids drotlet_IDs" 以数字标识从防火墙上移除 Drodlets. _ ___add-tags防火墙_id --tag-names tags' QQ 在防火墙上添加标记. QQ' remove-tags 防火墙_id-tag-names tags' 将标记从防火墙上移除. _ QQ'ad-rules 防火墙_id --入围规则 -- --出围规则 -- --出围规则 -- -- 在防火墙上添加入围规则或出围规则。 _ __移动规则'防火墙_id ——入门规则入门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门规则出门 |

当用作对doctl的参数时,输入或输出规则应表示为:protocol:protocol,ports:ports,droplet_id:droplet-id

与Tags合作

标签用于将自定义标签应用到资源中,允许您轻松过滤它们,您可以在 How To Tag DigitalOcean Droplets 教程中了解更多有关标签的信息。

doctl compute tag subcommandNotes
create tag_nameCreate a Tag.
get tag_nameGet a Tag by name.
listList all Tags.
delete tag_nameDelete a Tag by name.

与您的帐户合作

阅读您的帐户的行动历史

DigitalOcean系统记录了在您的Droplets、浮动IP和其他资源上所采取的操作的历史记录,您可以使用doctl compute action命令访问这些数据:

1doctl compute action list

您可以看到某个特定 Droplet 的操作如下:

1doctl compute droplet actions droplet_id

恢复您的帐户信息

您可以找到有关您的帐户的基本细节,例如配置的电子邮件地址和 Droplet 限制:

1doctl account get

由于 API 请求的速率有限,因此可以帮助您查看您最近做了多少次请求,以及何时需要重置限制:

1doctl account ratelimit

结论

doctl实用程序是一个有用的工具来管理命令行中的Dropplets和其他资源,它可以大大减少日常开发和管理任务所需的基于Web的界面的手动交互量。

除了了解 基础 API外,您还可以探索 包装流行的编程语言 API 的库,以及 [如 Ansible 等工具(https://andsky.com/tech/tutorials/how-to-create-ansible-playbooks-to-automate-system-configuration-on-ubuntu)用于自动化系统级任务。

Published At
Categories with 技术
comments powered by Disqus