Migrating to the :stable image
Stay organized with collections
Save and categorize content based on your preferences.
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
:stablebase image by customizing at runtime - Extending the
:stablebase image by building your own Dockerfile
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:
Create your own Dockerfile from
:stableby 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\ kubectlBuild the Dockerfile to get your own
:latestDocker image:$dockerbuild-tmy-cloud-sdk-docker:latest.
Build your own :emulators Image
To convert the :stable image into the :emulators image, do the following:
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}-0Build 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:
Create a Dockerfile using
:stableas 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\ gnupgBuild the Dockerfile by running the following command:
$dockerbuild-tmy-cloud-sdk-docker:slim.