Migrating to the :stable image

If you are using the :latest, :alpine, :emulators, :latest, :slim and :debian_component_based Docker images, we recommend that you migrate to debian based :stable image for a smaller image size and improved security fixes. To transition to using the :stable image you can extend the :stable Docker image to the debian based image you are using.

In some cases (i.e.- installing older incompatible dependencies like python2 or older jdks etc), extending the :stable image is not always feasible. In which case you may have to build your own Dockerfile.

Extending the :stable Docker image

You can use the :stable Docker image as a base image and install additional components and apt packages to extend it into the other debian based Docker images (i.e.- :latest, :emulators, and :slim). To extend the :stable Docker image, we can do one of the following:

Extending the :stable base image by customizing at runtime

You can extend the :stable Docker image to use as the :latest, :emulators or :slim image by customizing it at runtime.

Customize to the :latest Image

Run the following docker run command to extend the :stable Docker image into the :latest Docker image at run time:

$dockerrun-eAPT_PACKAGES='curl python3-crcmod apt-transport-https lsb-release openssh-client git make gnupg'\
-eCOMPONENTS='google-cloud-cli-datastore-emulator google-cloud-cli-pubsub-emulator google-cloud-cli-bigtable-emulator google-cloud-cli-firestore-emulator google-cloud-cli-spanner-emulator google-cloud-cli-cbt google-cloud-cli-kpt google-cloud-cli-local-extract google-cloud-cli-gke-gcloud-auth-plugin kubectl'\
gcr.io/google.com/cloudsdktool/google-cloud-cli:stablegcloudversion

Customize to the :emulators Image

You can run the following command to extend the :stable Docker image into the :emulators Docker image at runtime:

$dockerrun-eAPT_PACKAGES='curl python3-crcmod lsb-release gnupg bash'\
-eCOMPONENTS='google-cloud-cli-datastore-emulator google-cloud-cli-pubsub-emulator google-cloud-cli-bigtable-emulator google-cloud-cli-firestore-emulator google-cloud-cli-spanner-emulator'\
gcr.io/google.com/cloudsdktool/google-cloud-cli:stablegcloudversion

Customize to the :slim Image

You can extend the :stable Docker image as the :slim Docker image by running the following docker run command:

$dockerrun-eAPT_PACKAGES='curl gcc python3-crcmod python3-pip apt-transport-https lsb-release openssh-client git gnupg'\
gcr.io/google.com/cloudsdktool/google-cloud-cli:stablegcloudversion

Extending the :stable image with build configuration

You can use your own custom build configuration file(s) to extend the :stable Docker image to install additional packages or components. For example, if you want extend your :stable docker image to install python3-google-auth and python3-requests packages and install the pubsub emulator component, you can use the following build config file.

steps:
-id:'extend-stable'
name:gcr.io/google.com/cloudsdktool/google-cloud-cli:499.0.0-stable
args:
-gcloud
-version
env:
-'APT_PACKAGES=python3-google-authpython3-requests'
-'COMPONENTS=google-cloud-cli-pubsub-emulator'

Extending the :stable base image by building your own Dockerfile

You can extend the :stable Docker image by creating your own Dockerfile with :stable image as the base image and then build the docker image with docker build command.

Build your own :latest Image

To convert the :stable image into the :latest image, do the following:

  1. Create your own Dockerfile from :stable by installing the required components and packages:

    FROMdocker:27.1.1asstatic-docker-source
    FROMgcr.io/google.com/cloudsdktool/google-cloud-cli:stable
    COPY--from=static-docker-source/usr/local/bin/docker/usr/local/bin/docker
    COPY--from=static-docker-source/usr/local/libexec/docker/cli-plugins/docker-buildx/usr/local/libexec/docker/cli-plugins/docker-buildx
    RUNapt-getupdate-qqy && apt-get-qqyupgrade && apt-getinstall-qqy\
    curl\
    python3-crcmod\
    apt-transport-https\
    lsb-release\
    openssh-client\
    git\
    make\
    gnupg && \
    exportCLOUD_SDK_REPO="cloud-sdk-$(lsb_release-c-s)" && \
    exportCLOUD_SDK_VERSION=$(gcloudversion|grep"Google Cloud SDK"|grep-oE'[^ ]+$') && \
    echo"deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
    curlhttps://packages.cloud.google.com/apt/doc/apt-key.gpg|apt-keyadd- && \
    apt-getupdate && \
    apt-getinstall-ygoogle-cloud-cli-datastore-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-pubsub-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-bigtable-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-firestore-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-spanner-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-cbt=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-kpt=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-local-extract=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-gke-gcloud-auth-plugin=${CLOUD_SDK_VERSION}-0\
    kubectl
    
  2. Build the Dockerfile to get your own :latest Docker image:

    $dockerbuild-tmy-cloud-sdk-docker:latest.
    

Build your own :emulators Image

To convert the :stable image into the :emulators image, do the following:

  1. Create the Dockerfile with required components and packages as:

    FROMgcr.io/google.com/cloudsdktool/google-cloud-cli:stable
    RUNapt-getupdate-qqy && apt-get-qqyupgrade && apt-getinstall-qqy\
    curl\
    python3-crcmod\
    lsb-release\
    gnupg\
    bash && \
    exportCLOUD_SDK_REPO="cloud-sdk-$(lsb_release-c-s)" && \
    exportCLOUD_SDK_VERSION=$(gcloudversion|grep"Google Cloud SDK"|grep-oE'[^ ]+$') && \
    echo"deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
    curlhttps://packages.cloud.google.com/apt/doc/apt-key.gpg|apt-keyadd- && \
    apt-getupdate && \
    apt-getinstall-ygoogle-cloud-cli-datastore-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-pubsub-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-bigtable-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-firestore-emulator=${CLOUD_SDK_VERSION}-0\
    google-cloud-cli-spanner-emulator=${CLOUD_SDK_VERSION}-0
    
  2. Build the Dockerfile by running the command:

    $dockerbuild-tmy-cloud-sdk-docker:emulators.
    

Build your own :slim Image

To convert the :stable image into the :slim image, do the following:

  1. Create a Dockerfile using :stable as base image:

    FROMdocker:27.1.1asstatic-docker-source
    FROMgcr.io/google.com/cloudsdktool/google-cloud-cli:stable
    COPY--from=static-docker-source/usr/local/bin/docker/usr/local/bin/docker
    COPY--from=static-docker-source/usr/local/libexec/docker/cli-plugins/docker-buildx/usr/local/libexec/docker/cli-plugins/docker-buildx
    RUNapt-getupdate-qqy && apt-get-qqyupgrade && apt-getinstall-qqy\
    curl\
    python3-crcmod\
    apt-transport-https\
    lsb-release\
    openssh-client\
    git\
    make\
    gnupg
    
  2. Build the Dockerfile by running the following command:

    $dockerbuild-tmy-cloud-sdk-docker:slim.
    

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月29日 UTC.