The Cloud SDK Docker Image is essentially Cloud SDK installed on top of a Debian-based OS image.
This allows you to pull your desired version of Cloud SDK as a Docker image
from Dockerhub and quickly execute gcloud
commands within an isolated,
correctly configured container.
The Docker image itself is hosted on both Container Registry and Docker Hub, with the following repository names:
- Container Registry:
gcr.io/google.com/cloudsdktool/cloud-sdk
. - Docker Hub:
google/cloud-sdk
.
Docker image options
The Cloud SDK Docker images comes in three flavors; latest, slim, and alpine. You can specify your preference by using the appropriate tag (after the host repository name):
:latest
,:VERSION
: Large (Debian-based) image with additional components pre-installed:slim
,:VERSION-slim
: Smaller (Debian-based) image with no components pre-installed:alpine
,:VERSION-alpine
: Smallest (Alpine-based) image with no additional components installed
Installing a specified Docker image
To use the image of the latest Cloud SDK release,
gcr.io/google.com/cloudsdktool/cloud-sdk:latest
, pull it from Container Registry by running the following command:docker pull gcr.io/google.com/cloudsdktool/cloud-sdk:latest
Verify the installation (if you've pulled the latest version) by running:
docker run gcr.io/google.com/cloudsdktool/cloud-sdk:latest gcloud version
Alternatively, run this command for a specific version, 266.0.0:
docker run gcr.io/google.com/cloudsdktool/cloud-sdk:266.0.0 gcloud version
Authenticate with the gcloud command-line tool by running:
docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud auth login
Once you've authenticated successfully, credentials are preserved in the volume of the
gcloud-config container
.List compute instances using these credentials to verify by running the container with
--volumes-from
:docker run --rm --volumes-from gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud compute instances list --project your_project
Installing additional components
By default, the latest images (gcr.io/google.com/cloudsdktool/cloud-sdk:latest
and gcr.io/google.com/cloudsdktool/cloud-sdk:VERSION
) have all the gcloud
components installed.
The gcr.io/google.com/cloudsdktool/cloud-sdk:slim
and
gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
images, however, do not
come with additional components pre-installed. You can extend these
images by following the instructions below:
Debian-based images
To install an additional component, like google-cloud-sdk-datastore-emulator
,
run the following:
cd debian_slim/
docker build --build-arg CLOUD_SDK_VERSION=159.0.0 \
--build-arg INSTALL_COMPONENTS="google-cloud-sdk-datastore-emulator" \
-t my-cloud-sdk-docker:slim .
Alpine-based images
To install additional components for Alpine-based images, create a Dockerfile
that uses the Cloud SDK image as the base image. For example, to add
kubectl
and app-engine-java
components, create a Dockerfile to look like:
FROM gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
RUN apk --update add openjdk7-jre
RUN gcloud components install app-engine-java kubectl
Once done, run the following command:
docker build -t my-cloud-sdk-docker:alpine .
Installing specific versions of Cloud SDK
To install specific Cloud SDK versions, pass your preferred version in when
running the docker build
command, like so:
docker build -t my-cloud-sdk-docker:alpine --build-arg CLOUD_SDK_VERSION=<release_number> .