Migrating to the :stable image

If you are using the:latest,:alpine,:emulators,:latest,:slimand:debian_component_based Docker images, we recommend that you migrate todebian based:stable image for a smaller image size and improved securityfixes. To transition to using the:stable image you canextend the:stable Docker imageto the debian based image you are using.

In some cases (i.e.- installing older incompatible dependencies like python2 orolder jdks etc), extending the:stable image is not always feasible. In whichcase 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 installadditional components and apt packages to extend it intothe other debian based Docker images (i.e.-:latest,:emulators, and:slim). To extend the:stable Docker image, we can do one of thefollowing:

Extending the:stable base image by customizing at runtime

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

Customize to the:latest Image

Run the followingdocker run command to extend the:stable Dockerimage 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
Note: If you need a Docker engine installed in your Docker image, you canextend your:stable image by using it in a Dockerfile. For steps, seeExtending the:stable base image by building your own Dockerfile.

Customize to the:emulators Image

You can run the following command to extend the:stable Docker imageinto 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 byrunning the followingdocker 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
Note: If you need a docker engine installed in your Docker image, you canbuild your image from the pre-existing Dockerfiles. For steps, seeExtending the:stable base image by building your own Dockerfile.

Extending the:stable image with build configuration

You can use your own custombuild configurationfile(s) to extend the:stable Docker image to install additional packagesor components. For example, if you want extend your:stable docker image toinstallpython3-google-auth andpython3-requests packages and installthepubsub 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-stableargs:-gcloud-versionenv:-'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 ownDockerfile with:stable image as the base image and then build the dockerimage withdocker 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 requiredcomponents and packages:

    FROMdocker:27.1.1asstatic-docker-sourceFROMgcr.io/google.com/cloudsdktool/google-cloud-cli:stableCOPY--from=static-docker-source/usr/local/bin/docker/usr/local/bin/dockerCOPY--from=static-docker-source/usr/local/libexec/docker/cli-plugins/docker-buildx/usr/local/libexec/docker/cli-plugins/docker-buildxRUNapt-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:stableRUNapt-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-sourceFROMgcr.io/google.com/cloudsdktool/google-cloud-cli:stableCOPY--from=static-docker-source/usr/local/bin/docker/usr/local/bin/dockerCOPY--from=static-docker-source/usr/local/libexec/docker/cli-plugins/docker-buildx/usr/local/libexec/docker/cli-plugins/docker-buildxRUNapt-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 theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-16 UTC.