How install Cloud SDK Docker image from GCP?

xlmriosx

Lucas M. Rรญos

Posted on January 31, 2023

How install Cloud SDK Docker image from GCP?

๐Ÿงฐ Simple way to install SDK from GCP.


๐Ÿ”—Related content

You can find video related in:

๐Ÿ“บYouTube

You can find repo related in:

๐Ÿฑโ€๐ŸGitHub

You can connect with me in:

๐ŸงฌLinkedIn


Resume ๐Ÿงพ

I will install Docker image to use it as a SDK in Console GCP.

For more information and potential of this, click here.


1st - Pull Docker image โฌ‡

To use the image of the latest Cloud SDK release we will need pull image from repository in console.

I use following command:

CONSOLE:

docker pull gcr.io/google.com/cloudsdktool/cloud-sdk:latest
Enter fullscreen mode Exit fullscreen mode

OUTPUT:

latest: Pulling from google.com/cloudsdktool/cloud-sdk
50e431f79093: Pull complete
6005b060ba7d: Pull complete
c49059196e30: Pull complete
Digest: sha256:fd9985597827057effdb04fd1b07db9463f4a00ac24684cd3726c05e146eafa1
Status: Downloaded newer image for gcr.io/google.com/cloudsdktool/cloud-sdk:latest
gcr.io/google.com/cloudsdktool/cloud-sdk:latest
Enter fullscreen mode Exit fullscreen mode

2nd - Verifying installation โœ…

Verify the installation (if you've pulled the latest version) by running the following command:

CONSOLE:

docker run gcr.io/google.com/cloudsdktool/cloud-sdk:latest gcloud version
Enter fullscreen mode Exit fullscreen mode

OUTPUT:

Google Cloud SDK 284.0.0
alpha 2020.03.06
app-engine-go
app-engine-java 1.9.78
app-engine-python 1.9.88
app-engine-python-extras 1.9.88
beta 2020.03.06
bigtable
bq 2.0.54
cbt
cloud-datastore-emulator 2.1.0
core 2020.03.06
datalab 20190610
gsutil 4.48
kubectl 2020.03.06
pubsub-emulator 0.1.0
Enter fullscreen mode Exit fullscreen mode

3rd - Authenticate with the gcloud ๐Ÿ‘ค

We need authenticate to use gcloud tools. We can do that by the following command:

CONSOLE:

docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud auth login
Enter fullscreen mode Exit fullscreen mode

Note: Once we've authenticated successfully, credentials are preserved in the volume of the gcloud-config container.

OUTPUT:

Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?...


Enter verification code: ********

You are now logged in as [xlmriosx@gmail.com].
Your current project is [xlmriosx].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID
Enter fullscreen mode Exit fullscreen mode

4th - Creating an alias ๐Ÿ”ค

For simplicty create an alias by running:

CONSOLE:

alias csdk='docker run --rm --volumes-from gcloud-config -v ~/:/home/shared gcr.io/google.com/cloudsdktool/cloud-sdk'
Enter fullscreen mode Exit fullscreen mode

You can change if you want. In my case I prefer 'csdk' like a nice alias.


5th - List your projects ๐Ÿ“„

We can list projects by two forms a large and a short.

Large:
CONSOLE:

docker run --rm --volumes-from gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud projects list
Enter fullscreen mode Exit fullscreen mode

Short:
CONSOLE:

csdk gcloud projects list
Enter fullscreen mode Exit fullscreen mode

OUTPUT:

PROJECT_ID              NAME              PROJECT_NUMBER
xlmriosx                xlmriosx          783709003945
Enter fullscreen mode Exit fullscreen mode

6th - Prove change of a project ๐Ÿ”€

We can change name of projects by two ways a large and a short.

Large:
CONSOLE:

docker run --rm --volumes-from gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud config set project $PROJECT_NAME
Enter fullscreen mode Exit fullscreen mode

Short:
CONSOLE:

csdk gcloud config set project $PROJECT_NAME
Enter fullscreen mode Exit fullscreen mode

OUTPUT:

Updated property [core/project].
Enter fullscreen mode Exit fullscreen mode

7th - Say thanks, give like and share if this has been of help/interest ๐Ÿ˜๐Ÿ––


๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
xlmriosx
Lucas M. Rรญos

Posted on January 31, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About