gcloud compute instances update-container INSTANCE_NAME [--container-image=CONTAINER_IMAGE] [--container-mount-disk=[mode=MODE],[mount-path=MOUNT-PATH],[name=NAME],[partition=PARTITION]] [--container-privileged] [--container-restart-policy=POLICY] [--container-stdin] [--container-tty] [--[no-]shielded-integrity-monitoring] [--shielded-learn-integrity-policy] [--[no-]shielded-secure-boot] [--[no-]shielded-vtpm] [--zone=ZONE] [--clear-container-args | --container-arg=CONTAINER_ARG] [--clear-container-command | --container-command=CONTAINER_COMMAND] [--container-env=[KEY=VALUE, …,…] --container-env-file=CONTAINER_ENV_FILE --remove-container-env=[KEY,…]] [--container-mount-host-path=[host-path=HOSTPATH,mount-path=MOUNTPATH[,mode=MODE],…] --container-mount-tmpfs=[mount-path=MOUNTPATH,…] --remove-container-mounts=[MOUNTPATH[,MOUNTPATH,…],…]] [GCLOUD_WIDE_FLAG …]
(DEPRECATED) The option to deploy a container during VM creation
using the container startup agent is deprecated. Use alternative services to run
containers on your VMs. Learn more at https://cloud.google.com/compute/docs/containers/migrate-containers.
gcloud compute instances update-container updates Compute Engine
virtual machines that runs a Docker image. For example:
gcloud compute instances update-container instance-1 --zone us-central1-a --container-image=gcr.io/google-containers/busyboxupdates an instance called instance-1, in the us-central1-a zone, to run the 'busybox' image.
For more examples, refer to theEXAMPLES section below.
gcloud compute instances update-container instance-1 --container-image=gcr.io/google-containers/busybox --container-command='echo "Hello world"'To run the gcr.io/google-containers/busybox image in privileged mode, run:
gcloud compute instances update-container instance-1 --container-image=gcr.io/google-containers/busybox --container-privilegedINSTANCE_NAME--container-image=CONTAINER_IMAGE--container-mount-disk=[mode=MODE],[mount-path=MOUNT-PATH],[name=NAME],[partition=PARTITION]namemount-pathpartitionmoderw (read/write) or ro (read-only).
Defaults to rw. Fails if the disk mode is ro and
volume mount mode is rw.
--container-privileged--container-restart-policy=POLICYPOLICY must be one of: never,
on-failure, always.
--container-stdinSTDIN always open to
the specified value.
--container-tty--[no-]shielded-integrity-monitoringgcloud compute instances
update-container --shielded-learn-integrity-policy. On Shielded VM
instances, integrity monitoring is enabled by default. For information about how
to modify Shielded VM options, see https://cloud.google.com/compute/docs/instances/modifying-shielded-vm.
For information about monitoring integrity on Shielded VM instances, see
https://cloud.google.com/compute/docs/instances/integrity-monitoring." Changes
to this setting with the update command only take effect after stopping and
starting the instance. Use --shielded-integrity-monitoring to
enable and --no-shielded-integrity-monitoring to disable.
--shielded-learn-integrity-policy--[no-]shielded-secure-boot--shielded-secure-boot to enable and
--no-shielded-secure-boot to disable.
--[no-]shielded-vtpm--shielded-vtpm to enable and
--no-shielded-vtpm to disable.
--zone=ZONEgcloud attempts to identify the
appropriate zone by searching for resources in your currently active project. If
the zone cannot be determined, gcloud prompts you for a selection with
all available Google Cloud Platform zones.
To avoid prompting when this flag is omitted, the user can set the
property:
compute/zone
gcloud config set compute/zone ZONEA list of zones can be fetched by running:
gcloud compute zones listTo unset the property, run:
gcloud config unset compute/zoneCLOUDSDK_COMPUTE_ZONE.
At most one of these can be specified:
--clear-container-args--container-arg.
--container-arg=CONTAINER_ARG--clear-container-arg.
At most one of these can be specified:
--clear-container-command--container-command.
--container-command=CONTAINER_COMMAND--clear-container-command.
--container-env=[KEY=VALUE, …,…]KEY with value VALUE
passed to container.
KEY to the specified value.
KEY = VALUE, if KEY is not yet
declared.
KEY is taken when KEY is
repeated more than once.
--container-env flag override those with the
same KEY from file, provided in --container-env-file.
--container-env-file=CONTAINER_ENV_FILE--container-env apply. Values, declared with
--container-env flag override those with the same KEY
from file.
File with environment variables declarations in format used by docker (almost).
This means:
--remove-container-env=[KEY,…]KEY from container declaration Does
nothing, if a variable is not present.
--container-mount-host-path=[host-path=HOSTPATH,mount-path=MOUNTPATH[,mode=MODE],…]mount-path is not yet declared.
mount-path is declared. All parameters
(host-path, mount-path, mode) are
completely replaced.
host-pathmount-pathmode--container-mount-tmpfs=[mount-path=MOUNTPATH,…]mount-path--remove-container-mounts=[MOUNTPATH[,MOUNTPATH,…],…]host-path, tmpfs,
disk) with mountPath: MOUNTPATH from container
declaration.
Does nothing, if a volume mount is not declared.
--access-token-file,
--account, --billing-project,
--configuration,
--flags-file,
--flatten, --format, --help, --impersonate-service-account,
--log-http,
--project, --quiet, --trace-token, --user-output-enabled,
--verbosity.
Run $ gcloud help for details.
gcloud alpha compute instances update-containergcloud beta compute instances update-containergcloud preview compute instances update-container
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 2026-05-27 UTC.