DEV Community

Lucas M. Ríos
Lucas M. Ríos

Posted on

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 😁🖖


Top comments (0)