[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Migrating to the :stable image\n\nIf you are using the `:latest`, `:alpine`, `:emulators`, `:latest`, `:slim`\nand `:debian_component_based` Docker images, we recommend that you migrate to\ndebian based `:stable` image for a smaller image size and improved security\nfixes. To transition to using the `:stable` image you can\n[extend the `:stable` Docker image](#extending_the_stable_docker_image)\nto the debian based image you are using.\n\nIn some cases (i.e.- installing older incompatible dependencies like python2 or\nolder jdks etc), extending the `:stable` image is not always feasible. In which\ncase you may have to build your own Dockerfile.\n\nExtending the `:stable` Docker image\n------------------------------------\n\nYou can use the `:stable` Docker image as a base image and install\nadditional components and apt packages to extend it into\nthe other debian based Docker images (i.e.- `:latest`, `:emulators`, and\n`:slim`). To extend the `:stable` Docker image, we can do one of the\nfollowing:\n\n- [Extending the `:stable` base image by customizing at runtime](#extending_the_stable_base_image_by_customizing_at_runtime)\n- [Extending the `:stable` base image by building your own Dockerfile](#extending_the_stable_base_image_by_building_your_own_dockerfile)\n\n### Extending the `:stable` base image by customizing at runtime\n\nYou can extend the `:stable` Docker image to use as the `:latest`, `:emulators`\nor `:slim` image by customizing it at runtime.\n\n#### Customize to the `:latest` Image\n\nRun the following `docker run` command to extend the `:stable` Docker\nimage into the `:latest` Docker image at run time: \n\n $ docker run -e APT_PACKAGES='curl python3-crcmod apt-transport-https lsb-release openssh-client git make gnupg' \\\n -e COMPONENTS='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' \\\n gcr.io/google.com/cloudsdktool/google-cloud-cli:stable gcloud version\n\n| **Note:** If you need a Docker engine installed in your Docker image, you can extend your `:stable` image by using it in a Dockerfile. For steps, see [Extending the `:stable` base image by building your own Dockerfile](#extending_the_stable_base_image_by_building_your_own_dockerfile).\n\n#### Customize to the `:emulators` Image\n\nYou can run the following command to extend the `:stable` Docker image\ninto the `:emulators` Docker image at runtime: \n\n $ docker run -e APT_PACKAGES='curl python3-crcmod lsb-release gnupg bash' \\\n -e COMPONENTS='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' \\\n gcr.io/google.com/cloudsdktool/google-cloud-cli:stable gcloud version\n\n#### Customize to the `:slim` Image\n\nYou can extend the `:stable` Docker image as the `:slim` Docker image by\nrunning the following `docker run` command: \n\n $ docker run -e APT_PACKAGES='curl gcc python3-crcmod python3-pip apt-transport-https lsb-release openssh-client git gnupg' \\\n gcr.io/google.com/cloudsdktool/google-cloud-cli:stable gcloud version\n\n| **Note:** If you need a docker engine installed in your Docker image, you can build your image from the pre-existing Dockerfiles. For steps, see [Extending the `:stable` base image by building your own Dockerfile](#extending_the_stable_base_image_by_building_your_own_dockerfile).\n\n#### Extending the `:stable` image with build configuration\n\nYou can use your own custom [build configuration](/build/docs/build-config-file-schema)\nfile(s) to extend the `:stable` Docker image to install additional packages\nor components. For example, if you want extend your `:stable` docker image to\ninstall `python3-google-auth` and `python3-requests` packages and install\nthe `pubsub emulator` component, you can use the following build config file. \n\n steps:\n - id: 'extend-stable'\n name: gcr.io/google.com/cloudsdktool/google-cloud-cli:499.0.0-stable\n args:\n - gcloud\n - version\n env:\n - 'APT_PACKAGES=python3-google-auth python3-requests'\n - 'COMPONENTS=google-cloud-cli-pubsub-emulator'\n\n### Extending the `:stable` base image by building your own Dockerfile\n\nYou can extend the `:stable` Docker image by creating your own\nDockerfile with `:stable` image as the base image and then build the docker\nimage with `docker build` command.\n\n#### Build your own `:latest` Image\n\nTo convert the `:stable` image into the `:latest` image, do the following:\n\n1. Create your own Dockerfile from `:stable` by installing the required\n components and packages:\n\n FROM docker:27.1.1 as static-docker-source\n\n FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:stable\n COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker\n COPY --from=static-docker-source /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx\n\n RUN apt-get update -qqy && apt-get -qqy upgrade && apt-get install -qqy \\\n curl \\\n python3-crcmod \\\n apt-transport-https \\\n lsb-release \\\n openssh-client \\\n git \\\n make \\\n gnupg && \\\n export CLOUD_SDK_REPO=\"cloud-sdk-$(lsb_release -c -s)\" && \\\n export CLOUD_SDK_VERSION=$(gcloud version | grep \"Google Cloud SDK\" | grep -oE '[^ ]+$') && \\\n echo \"deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main\" \u003e /etc/apt/sources.list.d/google-cloud-sdk.list && \\\n curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \\\n apt-get update && \\\n apt-get install -y google-cloud-cli-datastore-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-pubsub-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-bigtable-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-firestore-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-spanner-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-cbt=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-kpt=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-local-extract=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-gke-gcloud-auth-plugin=${CLOUD_SDK_VERSION}-0 \\\n kubectl\n\n2. Build the Dockerfile to get your own `:latest` Docker image:\n\n $ docker build -t my-cloud-sdk-docker:latest .\n\n#### Build your own `:emulators` Image\n\nTo convert the `:stable` image into the `:emulators` image, do the following:\n\n1. Create the Dockerfile with required components and packages as:\n\n FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:stable\n\n RUN apt-get update -qqy && apt-get -qqy upgrade && apt-get install -qqy \\\n curl \\\n python3-crcmod \\\n lsb-release \\\n gnupg \\\n bash && \\\n export CLOUD_SDK_REPO=\"cloud-sdk-$(lsb_release -c -s)\" && \\\n export CLOUD_SDK_VERSION=$(gcloud version | grep \"Google Cloud SDK\" | grep -oE '[^ ]+$') && \\\n echo \"deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main\" \u003e /etc/apt/sources.list.d/google-cloud-sdk.list && \\\n curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \\\n apt-get update && \\\n apt-get install -y google-cloud-cli-datastore-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-pubsub-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-bigtable-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-firestore-emulator=${CLOUD_SDK_VERSION}-0 \\\n google-cloud-cli-spanner-emulator=${CLOUD_SDK_VERSION}-0\n\n2. Build the Dockerfile by running the command:\n\n $ docker build -t my-cloud-sdk-docker:emulators .\n\n#### Build your own `:slim` Image\n\nTo convert the `:stable` image into the `:slim` image, do the following:\n\n1. Create a Dockerfile using `:stable` as base image:\n\n FROM docker:27.1.1 as static-docker-source\n\n FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:stable\n COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker\n COPY --from=static-docker-source /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx\n\n RUN apt-get update -qqy && apt-get -qqy upgrade && apt-get install -qqy \\\n curl \\\n python3-crcmod \\\n apt-transport-https \\\n lsb-release \\\n openssh-client \\\n git \\\n make \\\n gnupg\n\n2. Build the Dockerfile by running the following command:\n\n $ docker build -t my-cloud-sdk-docker:slim ."]]