コンテンツにスキップ

DigitalOcean CLI (doctl)

ドロップレット、ロードバランサー、データベース、Kubernetesクラスターを管理するための包括的なDigitalOcean CLIコマンドとワークフロー。

インストールと認証

コマンド説明
doctl auth init認証を初期化する
doctl auth list認証コンテキストを一覧表示
doctl auth switch --context CONTEXT_NAMESwitch認証コンテキスト
doctl account getアカウント情報を取得
doctl balance getアカウント残高を取得

ドロップレット(仮想マシン)

ドロップレット管理

コマンド説明
doctl compute droplet listすべてのドロップレットを一覧表示
doctl compute droplet create mydroplet --size s-1vcpu-1gb --image ubuntu-20-04-x64 --region nyc1ドロップレットを作成
doctl compute droplet delete DROPLET_IDドロップレットを削除
doctl compute droplet get DROPLET_IDドロップレットの詳細を取得
doctl compute droplet reboot DROPLET_IDドロップレットを再起動
doctl compute droplet power-off DROPLET_IDドロップレットの電源を切る
doctl compute droplet power-on DROPLET_IDドロップレットの電源を入れる
doctl compute droplet shutdown DROPLET_IDドロップレットをシャットダウン

ドロップレットのアクション

コマンド説明
doctl compute droplet-action list DROPLET_IDドロップレットのアクション一覧
doctl compute droplet-action resize DROPLET_ID --size s-2vcpu-2gbドロップレットのサイズ変更
doctl compute droplet-action snapshot DROPLET_ID --snapshot-name my-snapshotスナップショットを作成
doctl compute droplet-action restore DROPLET_ID --image IMAGE_ID画像から復元
doctl compute droplet-action rebuild DROPLET_ID --image ubuntu-20-04-x64ドロップレットを再構築

SSHとアクセス

コマンド説明
doctl compute ssh DROPLET_NAMESSH で droplet に接続する
doctl compute ssh DROPLET_NAME --ssh-user root特定のユーザーでSSH接続
doctl compute ssh-key listSSHキーを一覧表示
doctl compute ssh-key create --name mykey --public-key-file ~/.ssh/id_rsa.pubSSHキーを追加
doctl compute ssh-key delete KEY_IDSSHキーを削除

イメージとスナップショット

コマンド説明
doctl compute image listすべての画像を一覧表示
doctl compute image list --publicパブリックイメージを一覧表示
doctl compute image list-userユーザーイメージの一覧
doctl compute image get IMAGE_ID画像の詳細を取得
doctl compute image delete IMAGE_ID画像を削除
doctl compute image update IMAGE_ID --name new-nameイメージ名を更新

ボリューム(ブロックストレージ)

コマンド説明
doctl compute volume listすべてのボリュームを一覧表示
doctl compute volume create myvolume --size 100GiB --region nyc1ボリュームを作成
doctl compute volume delete VOLUME_IDボリュームを削除
doctl compute volume attach VOLUME_ID DROPLET_IDボリュームをドロップレットにアタッチする
doctl compute volume detach VOLUME_IDボリュームを切断
doctl compute volume snapshot VOLUME_ID --snapshot-name my-volume-snapshotボリュームスナップショットを作成

ロードバランサー

コマンド説明
doctl compute load-balancer listロードバランサーの一覧
doctl compute load-balancer create --name mylb --forwarding-rules entry_protocol:http,entry_port:80,target_protocol:http,target_port:80 --region nyc1ロードバランサーを作成
doctl compute load-balancer delete LB_IDロードバランサーを削除
doctl compute load-balancer add-droplets LB_ID --droplet-ids DROPLET_ID1,DROPLET_ID2LBに滴を加える
doctl compute load-balancer remove-droplets LB_ID --droplet-ids DROPLET_ID1LBからドロップレットを削除

ネットワーキング

ファイアウォール

コマンド説明
doctl compute firewall listファイアウォールのリスト
doctl compute firewall create --name myfirewall --inbound-rules protocol:tcp,ports:22,sources:0.0.0.0/0ファイアウォールを作成
doctl compute firewall delete FIREWALL_IDファイアウォールを削除
doctl compute firewall add-droplets FIREWALL_ID --droplet-ids DROPLET_IDファイアウォールにドロップレットを追加
doctl compute firewall remove-droplets FIREWALL_ID --droplet-ids DROPLET_IDファイアウォールからドロップレットを削除

VPCネットワーク

コマンド説明
doctl vpcs listVPCをリスト
doctl vpcs create --name myvpc --region nyc1VPCを作成
doctl vpcs delete VPC_IDVPCを削除
doctl vpcs get VPC_IDVPCの詳細を取得

フローティングIP

コマンド説明
doctl compute floating-ip listフローティングIPをリスト
doctl compute floating-ip create --region nyc1フローティング IP を作成
doctl compute floating-ip delete FLOATING_IPフローティングIPを削除
doctl compute floating-ip-action assign FLOATING_IP DROPLET_IDフローティングIPを割り当てる
doctl compute floating-ip-action unassign FLOATING_IPフローティングIPの割り当て解除

Kubernetes (DOKS)

クラスター管理

コマンド説明
doctl kubernetes cluster listKubernetesクラスターを一覧表示
doctl kubernetes cluster create mycluster --region nyc1 --node-pool "name=worker-pool;size=s-2vcpu-2gb;count=3"クラスターを作成
doctl kubernetes cluster delete CLUSTER_IDクラスターを削除
doctl kubernetes cluster get CLUSTER_IDクラスターの詳細を取得
doctl kubernetes cluster kubeconfig save CLUSTER_IDkubeconfig を保存

ノードプール

コマンド説明
doctl kubernetes cluster node-pool list CLUSTER_IDノードプールをリスト
doctl kubernetes cluster node-pool create CLUSTER_ID --name new-pool --size s-2vcpu-2gb --count 2ノードプールを作成
doctl kubernetes cluster node-pool delete CLUSTER_ID POOL_IDノードプールを削除
doctl kubernetes cluster node-pool resize CLUSTER_ID POOL_ID --count 5ノードプールのサイズ変更

データベース

データベースクラスター

コマンド説明
doctl databases listデータベースクラスターを一覧表示
doctl databases create mydb --engine mysql --size db-s-1vcpu-1gb --region nyc1データベースクラスターを作成
doctl databases delete DATABASE_IDデータベースクラスターを削除
doctl databases get DATABASE_IDデータベースの詳細を取得
doctl databases resize DATABASE_ID --size db-s-2vcpu-2gbデータベースのサイズ変更

データベース操作

コマンド説明
doctl databases db list DATABASE_IDデータベースをリスト
doctl databases db create DATABASE_ID --name myappデータベースを作成する
doctl databases db delete DATABASE_ID myappデータベースを削除
doctl databases user list DATABASE_IDデータベースユーザーを一覧表示
doctl databases user create DATABASE_ID --username myuserデータベースユーザーを作成する

データベースバックアップ

コマンド説明
doctl databases backups list DATABASE_IDバックアップをリスト
doctl databases backups restore DATABASE_ID BACKUP_IDバックアップから復元

Spaces(オブジェクトストレージ)

コマンド説明
doctl compute cdn listCDNエンドポイントをリスト
doctl compute cdn create --origin spaces.example.com --domain cdn.example.comCDNエンドポイントを作成
doctl compute cdn delete CDN_IDCDNエンドポイントを削除

アプリプラットフォーム

アプリ管理

コマンド説明
doctl apps listアプリリスト
doctl apps create --spec app.yaml仕様からアプリを作成
doctl apps get APP_IDアプリの詳細を取得
doctl apps delete APP_IDアプリを削除
doctl apps update APP_ID --spec app.yamlアプリを更新

アプリデプロイメント

コマンド説明
doctl apps list-deployments APP_IDデプロイメントをリスト
doctl apps get-deployment APP_ID DEPLOYMENT_IDデプロイメントの詳細を取得
doctl apps logs APP_ID --type buildビルドログを取得
doctl apps logs APP_ID --type runランタイムログを取得

モニタリング

アラート

Would you like me to continue with the remaining sections?

コマンド説明
doctl monitoring alert listList alert policies
doctl monitoring alert create --spec alert.yamlCreate alert policy
doctl monitoring alert delete ALERT_IDアラートポリシーを削除
doctl monitoring alert get ALERT_IDアラートの詳細を取得

プロジェクト

コマンド説明
doctl projects listプロジェクトをリスト
doctl projects create --name myproject --description "My project"プロジェクトを作成
doctl projects get PROJECT_IDプロジェクトの詳細を取得
doctl projects update PROJECT_ID --name "New name"プロジェクトを更新
doctl projects resources list PROJECT_IDプロジェクトリソースをリスト

リージョンとサイズ

コマンド説明
doctl compute region list利用可能なリージョンを一覧表示
doctl compute size list利用可能なドロップレットサイズの一覧
doctl kubernetes options regionsKubernetesリージョンをリスト
doctl kubernetes options versionsKubernetesバージョンの一覧
doctl databases options enginesデータベースエンジンの一覧
doctl databases options sizesデータベースサイズの一覧