Before the installation of the gcloud CLI, please confirm that the following conditions are met:
The OS release has not reached the end-of-life.
The apt-transport-http package is installed. If not, use the following command to install it:
sudo apt-get install apt-transport-https ca-certificates gnupg
The Google Cloud CLI contains the following command-line tools and supported commands:
| Command-line Tools | Supported Commands |
|---|---|
gcloud |
gcloud, gcloud alpha, gcloud beta |
gsutil |
gsutil |
bq |
bs |
However, this package does not contain kubectl or deployment extensions of App Engine but these can be installed.
Perform the following steps to install the Google Cloud CLI:
gcloud CLI distributionUse the following command to add the gcloud CLI distribution URI as a packet source:
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
Note: Verify that there aren’t any duplicated data for the
cloud-sdkrepo in/etc/apt/sources.list.d/google-cloud-sdk.list.
You can acquire the public Key for Google Cloud by executing one of the following commands depending on the type of your distribution:
apt-key command supports the --keyring argument:curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
apt-key command does not support the --keyring argument:curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
apt-key:curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/cloud.google.gpg
gcloudRun the following command to update and install the gcloud CLI:
sudo apt-get update && sudo apt-get install google-cloud-cli
Additional components of Google Cloud can be installed using the following command:
sudo apt-get install [component_name]
gcloud CLIUse the following command to initialize the gcloud CLI:
gcloud init
If you want to install the gcloud CLI inside the Docker image, you can use the following single RUN command:
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-cli -y
If apt-key is not supported in the Docker image, use the following:
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | tee /usr/share/keyrings/cloud.google.gpg && apt-get update -y && apt-get install google-cloud-sdk -y
Unlock your potential: Google Cloud CLI installation series, all in one place!
To continue your exploration of Google Cloud CLI installation, check out our series of Answers below:
How to install Google Cloud CLI on macOS?
Step-by-step instructions for installing Google Cloud CLI on macOS.
How to install Google Cloud CLI on Windows?
Learn how to set up Google Cloud CLI on Windows for seamless cloud interactions.
How to install Google Cloud CLI on Debian/Ubuntu?
Get the necessary commands to install Google Cloud CLI on Debian/Ubuntu Linux distributions.
How to install Google Cloud CLI on Linux?
Explore the process of setting up Google Cloud CLI on Linux systems for command-line cloud access.
Free Resources