Help us understand the problem. What is going on with this article?

Dockerhubに登録されているgoogle/cloud-sdkを利用してgcloudコマンドを使用する

More than 1 year has passed since last update.

Googleがdockerhubにgcloudを含むsdkのdocker imageを用意しているので、これを使用する。

dockerhub google/cloud-sdk
Cloud SDK | Cloud SDK | Google Cloud

手順

# pull
$ docker pull google/cloud-sdk:latest

# versionとplugin確認
$ docker run -ti  google/cloud-sdk:latest gcloud version

# config保存用volume作成
# credentialが含まれるので、不用心に他のcontainerでこのvolumeを使用しない
$ docker volume create gcloud-config

# auth これを実行すると `gcloud-config` containerのvolumeに認証情報が保存される
# 実行するとURLが表示されるので、それにアクセスして認証したいgoogle accountで設定する
# 設定内容は ~/.config/gcloud に保存されている
$ docker run -ti -v gcloud-config:/root/.config/gcloud google/cloud-sdk gcloud auth login

# gcloudの使用
$ docker run --rm -ti -v gcloud-config:/root/.config/gcloud google/cloud-sdk gcloud compute instances list --project your_project

gcloudのupdateは最新のimageを持ってくる

$ docker pull google/cloud-sdk:latest
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした