gcloud compute instances create-with-container INSTANCE_NAMES [INSTANCE_NAMES …] [--accelerator=[count=COUNT],[type=TYPE]] [--no-boot-disk-auto-delete] [--boot-disk-device-name=BOOT_DISK_DEVICE_NAME] [--boot-disk-interface=BOOT_DISK_INTERFACE] [--boot-disk-provisioned-iops=BOOT_DISK_PROVISIONED_IOPS] [--boot-disk-provisioned-throughput=BOOT_DISK_PROVISIONED_THROUGHPUT] [--boot-disk-size=BOOT_DISK_SIZE] [--boot-disk-type=BOOT_DISK_TYPE] [--can-ip-forward] [--container-arg=CONTAINER_ARG] [--container-command=CONTAINER_COMMAND] [--container-env=[KEY=VALUE, …,…]] [--container-env-file=CONTAINER_ENV_FILE] [--container-image=CONTAINER_IMAGE] [--container-mount-disk=[mode=MODE],[mount-path=MOUNT-PATH],[name=NAME],[partition=PARTITION]] [--container-mount-host-path=[host-path=HOSTPATH,mount-path=MOUNTPATH[,mode=MODE],…]] [--container-mount-tmpfs=[mount-path=MOUNTPATH,…]] [--container-privileged] [--container-restart-policy=POLICY; default="always"] [--container-stdin] [--container-tty] [--create-disk=[PROPERTY=VALUE,…]] [--description=DESCRIPTION] [--discard-local-ssds-at-termination-timestamp=DISCARD_LOCAL_SSDS_AT_TERMINATION_TIMESTAMP] [--disk=[auto-delete=AUTO-DELETE],[boot=BOOT],[device-name=DEVICE-NAME],[force-attach=FORCE-ATTACH],[interface=INTERFACE],[mode=MODE],[name=NAME],[scope=SCOPE]] [--[no-]enable-nested-virtualization] [--external-ipv6-address=EXTERNAL_IPV6_ADDRESS] [--external-ipv6-prefix-length=EXTERNAL_IPV6_PREFIX_LENGTH] [--host-error-timeout-seconds=HOST_ERROR_TIMEOUT_SECONDS] [--instance-termination-action=INSTANCE_TERMINATION_ACTION] [--internal-ipv6-address=INTERNAL_IPV6_ADDRESS] [--internal-ipv6-prefix-length=INTERNAL_IPV6_PREFIX_LENGTH] [--ipv6-network-tier=IPV6_NETWORK_TIER] [--labels=[KEY=VALUE,…]] [--local-ssd-recovery-timeout=LOCAL_SSD_RECOVERY_TIMEOUT] [--machine-type=MACHINE_TYPE] [--maintenance-policy=MAINTENANCE_POLICY] [--max-run-duration=MAX_RUN_DURATION] [--metadata=KEY=VALUE,[KEY=VALUE,…]] [--metadata-from-file=KEY=LOCAL_FILE_PATH,[…]] [--min-cpu-platform=PLATFORM] [--network=NETWORK] [--network-interface=[PROPERTY=VALUE,…]] [--network-performance-configs=[PROPERTY=VALUE,…]] [--network-tier=NETWORK_TIER] [--preemptible] [--private-ipv6-google-access-type=PRIVATE_IPV6_GOOGLE_ACCESS_TYPE] [--private-network-ip=PRIVATE_NETWORK_IP] [--provisioning-model=PROVISIONING_MODEL] [--request-valid-for-duration=REQUEST_VALID_FOR_DURATION] [--resource-policies=[RESOURCE_POLICY,…]] [--no-restart-on-failure] [--shielded-integrity-monitoring] [--shielded-secure-boot] [--shielded-vtpm] [--[no-]skip-guest-os-shutdown] [--source-instance-template=SOURCE_INSTANCE_TEMPLATE] [--stack-type=STACK_TYPE] [--subnet=SUBNET] [--tags=TAG,[TAG,…]] [--termination-time=TERMINATION_TIME] [--threads-per-core=THREADS_PER_CORE] [--visible-core-count=VISIBLE_CORE_COUNT] [--zone=ZONE] [--address=ADDRESS | --no-address] [--confidential-compute | --confidential-compute-type=CONFIDENTIAL_COMPUTE_TYPE] [--custom-cpu=CUSTOM_CPU --custom-memory=CUSTOM_MEMORY : --custom-extensions --custom-vm-type=CUSTOM_VM_TYPE] [--image-project=IMAGE_PROJECT --image=IMAGE | --image-family=IMAGE_FAMILY] [--public-ptr | --no-public-ptr] [--public-ptr-domain=PUBLIC_PTR_DOMAIN | --no-public-ptr-domain] [--reservation=RESERVATION --reservation-affinity=RESERVATION_AFFINITY; default="any"] [--scopes=[SCOPE,…] | --no-scopes] [--service-account=SERVICE_ACCOUNT | --no-service-account] [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 create-with-container creates Compute
Engine virtual machines that runs a Docker image. For example:
gcloud compute instances create-with-container instance-1 --zone us-central1-a --container-image=gcr.io/google-containers/busyboxcreates an instance called instance-1, in the us-central1-a zone, running the 'busybox' image.
For more examples, refer to theEXAMPLES section below.
gcloud compute instances create-with-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 create-with-container instance-1 --container-image=gcr.io/google-containers/busybox --container-privilegedINSTANCE_NAMES [INSTANCE_NAMES …]--accelerator=[count=COUNT],[type=TYPE]typecount--boot-disk-auto-delete--no-boot-disk-auto-delete to disable.
--boot-disk-device-name=BOOT_DISK_DEVICE_NAME--boot-disk-interface=BOOT_DISK_INTERFACE--boot-disk-provisioned-iops=BOOT_DISK_PROVISIONED_IOPS--boot-disk-provisioned-throughput=BOOT_DISK_PROVISIONED_THROUGHPUT--boot-disk-size=BOOT_DISK_SIZEKB for kilobyte,
MB for megabyte,
GB for gigabyte, or
TB for terabyte. For example,
10GB will produce a 10 gigabyte disk. Disk
size must be a multiple of 1 GB. Default size unit is
GB.
--boot-disk-type=BOOT_DISK_TYPE$ gcloud compute disk-types
list.
--can-ip-forward--container-arg=CONTAINER_ARGAssuming the default entry point of the container (or an entry point overridden with --container-command flag) is a Bourne shell-compatible executable, in order to execute 'ls -l' command in the container, the user could use:
--container-arg="-c" --container-arg="ls -l"
Caveat: due to the nature of the argument parsing, it's impossible to provide
the flag value that starts with a dash (-) without the
= sign (that is, --container-arg "-c" will not work
correctly).
--container-command=CONTAINER_COMMANDnc.
Default: None (default container entrypoint is used)
--container-env=[KEY=VALUE, …,…]--container-env-file=CONTAINER_ENV_FILE# is first non-whitespace character in a line the line is
ignored as a comment.
--container-image=CONTAINER_IMAGEdocker.io/tomcat.
--container-mount-disk=[mode=MODE],[mount-path=MOUNT-PATH],[name=NAME],[partition=PARTITION]--disk or --create-disk.
name--disk or --create-disk, specifying disk name
here is optional. The name of the single additional disk will be used by
default.
mount-pathpartitionmoderw (read/write) or ro (read-only).
Defaults to rw. Fails if the disk mode is ro and
volume mount mode is rw.
--container-mount-host-path=[host-path=HOSTPATH,mount-path=MOUNTPATH[,mode=MODE],…]host-pathmount-pathmode--container-mount-tmpfs=[mount-path=MOUNTPATH,…]mount-path--container-privileged--no-container-privileged.
--container-restart-policy=POLICY; default="always"POLICY
must be one of: never, on-failure,
always.
--container-stdin--no-container-stdin.
--container-tty--no-container-tty.
--create-disk=[PROPERTY=VALUE,…]name--container-mount-disk.
descriptionmodero for read-only and
rw for read-write. If omitted,
rw is used as a default. It is an error to
create a disk in ro mode if attaching it to a container with
--container-mount-disk.
image$ gcloud compute images
list. It is best practice to use image when a specific version of an
image is needed. If both image and image-family flags are omitted a blank disk
will be created.
image-familyimage-projectgcloud compute images
list.
sizeKB for kilobyte,
MB for megabyte,
GB for gigabyte, or
TB for terabyte. For example,
10GB will produce a 10 gigabyte disk. Disk
size must be a multiple of 1 GB. If not specified, the default image size will
be used for the new disk.
typepd-standard.
device-namename if used with --container-mount-disk.
If omitted, a device name of the form persistent-disk-N is used. If
omitted and used with --container-mount-disk (where the
name of the container mount disk is the same as in this flag), a
device name equal to disk name is used.
provisioned-iopsprovisioned-throughputdisk-resource-policyhttps://www.googleapis.com/compute/v1/projects/my-project/regions/us-central1/resourcePolicies/my-resource-policy
projects/my-project/regions/us-central1/resourcePolicies/my-resource-policy
auto-deleteyes, this persistent disk will be
automatically deleted when the instance is deleted. However, if the disk is
later detached from the instance, this option won't apply. The default value for
this is yes.
architecturestorage-poolinterfacereplica-zones--description=DESCRIPTION--discard-local-ssds-at-termination-timestamp=DISCARD_LOCAL_SSDS_AT_TERMINATION_TIMESTAMPtrue and only allowed for VMs that have one
or more local SSDs, use --instance-termination-action=STOP, and use either
--max-run-duration or --termination-time.
This flag indicates the value that you want Compute Engine to use for the
--discard-local-ssd flag in the automatic gcloud compute instances
stop command. This flag only supports the true value,
which discards local SSD data when automatically stopping this VM during its
terminationTimestamp.
--discard-local-ssd flag, see https://cloud.google.com/compute/docs/disks/local-ssd#stop_instance.
--disk=[auto-delete=AUTO-DELETE],[boot=BOOT],[device-name=DEVICE-NAME],[force-attach=FORCE-ATTACH],[interface=INTERFACE],[mode=MODE],[name=NAME],[scope=SCOPE]nameprojects/myproject/regions/us-central1/disks/my-regional-disk.
modero for read-only mode and
rw for read-write mode. If omitted,
rw is used as a default value. If you use
rw when creating more than one instance,
you encounter errors.
bootyes, you attach a boot disk. The
virtual machine then uses the first partition of the disk for the root file
systems. The default value for this is no.
device-namename if used with --container-mount-disk.
If omitted, a device name of the form persistent-disk-N is used. If
omitted and used with --container-mount-disk (where the
name of the container mount disk is the same as in this flag), a
device name equal to disk name is used.
auto-deleteyes, the persistent disk is
automatically deleted when the instance is deleted. However, if you detach the
disk from the instance, deleting the instance doesn't delete the disk. The
default value is yes.
interfacescopezonal or regional. If
zonal, the disk is interpreted as a zonal
disk in the same zone as the instance (default). If
regional, the disk is interpreted as a
regional disk in the same region as the instance. The default value for this is
zonal.
force-attachyes, this persistent disk will
force-attached to the instance even it is already attached to another instance.
The default value is 'no'.
--[no-]enable-nested-virtualization--enable-nested-virtualization to enable and
--no-enable-nested-virtualization to disable.
--external-ipv6-address=EXTERNAL_IPV6_ADDRESS--external-ipv6-prefix-length=EXTERNAL_IPV6_PREFIX_LENGTH--external-ipv6-address. Only the /96 IP address
range is supported, and the default value is 96.
--host-error-timeout-seconds=HOST_ERROR_TIMEOUT_SECONDS--instance-termination-action=INSTANCE_TERMINATION_ACTIONINSTANCE_TERMINATION_ACTION must be one of:
DELETESTOP--internal-ipv6-address=INTERNAL_IPV6_ADDRESS--internal-ipv6-prefix-length=INTERNAL_IPV6_PREFIX_LENGTH--ipv6-network-tier=IPV6_NETWORK_TIERIPV6_NETWORK_TIER
must be (only one value is supported):
PREMIUM--labels=[KEY=VALUE,…]-), underscores (_), lowercase characters, and
numbers. Values must contain only hyphens (-), underscores
(_), lowercase characters, and numbers.
--local-ssd-recovery-timeout=LOCAL_SSD_RECOVERY_TIMEOUT--machine-type=MACHINE_TYPE--maintenance-policy=MAINTENANCE_POLICYMAINTENANCE_POLICY must be one of:
MIGRATETERMINATE--max-run-duration=MAX_RUN_DURATION30m for a duration of 30 minutes
or specify 1d2h3m4s for a duration of 1 day, 2 hours, 3 minutes,
and 4 seconds. Alternatively, to specify a timestamp, use --termination-time
instead.
If neither --max-run-duration nor --termination-time is specified (default), the
VM instance runs until prompted by a user action or system event. If either is
specified, the VM instance is scheduled to be automatically terminated at the
VM's termination timestamp (terminationTimestamp) using the action
specified by --instance-termination-action.
terminationTimestamp is removed whenever the VM is
stopped or suspended and redefined whenever the VM is rerun. For
--max-run-duration specifically, the terminationTimestamp is the
sum of MAX_RUN_DURATION and the time when the VM last entered the
RUNNING state, which changes whenever the VM is rerun.
--metadata=KEY=VALUE,[KEY=VALUE,…]--metadata
key-1=value-1,key-2=value-2,key-3=value-3. The combined
total size for all metadata entries is 512 KB.
In images that have Compute Engine tools installed on them, such as the official images, the
following metadata keys have special meanings:
startup-script--metadata-from-file can be used to pull
the value from a file.
startup-script-urlstartup-script except that the
script contents are pulled from a publicly-accessible location on the web.
For startup scripts on Windows instances, the following metadata keys have
special meanings:
windows-startup-script-url,
windows-startup-script-cmd,
windows-startup-script-bat,
windows-startup-script-ps1,
sysprep-specialize-script-url,
sysprep-specialize-script-cmd,
sysprep-specialize-script-bat, and
sysprep-specialize-script-ps1. For more
information, see Running startup
scripts.
--metadata-from-file=KEY=LOCAL_FILE_PATH,[…]--metadata except that the value
for the entry will be read from a local file. This is useful for values that are
too large such as startup-script contents.
--min-cpu-platform=PLATFORMgcloud compute zones describe ZONE --format="value(availableCpuPlatforms)"Default setting is "AUTOMATIC".
CPU platform selection is available only in selected zones.
You can find more information on-line: https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform--network=NETWORK--subnet is also specified, subnet must be a subnetwork of the
network specified by this --network flag. If neither is specified,
the default network is used.
--network-interface=[PROPERTY=VALUE,…]--address, --network,
--network-tier, --subnet,
--private-network-ip, --stack-type,
--ipv6-network-tier, --internal-ipv6-address,
--internal-ipv6-prefix-length, --ipv6-address,
--ipv6-prefix-length, --external-ipv6-address,
--external-ipv6-prefix-length. This flag can be repeated to specify
multiple network interfaces.
The following keys are allowed:
addressnetworkno-addressnetwork-tierNETWORK_TIER must be one of:
PREMIUM, STANDARD. The default value is
PREMIUM.
private-network-ipsubnetnic-typeNIC_TYPE must be one of:
GVNIC, VIRTIO_NET.
stack-typeSTACK_TYPE must be one of:
IPV4_ONLY, IPV4_IPV6, IPV6_ONLY. The
default value is IPV4_ONLY.
ipv6-network-tierIPV6_NETWORK_TIER must be
PREMIUM (currently only one value is supported).
internal-ipv6-addressinternal-ipv6-prefix-lengthexternal-ipv6-addressexternal-ipv6-prefix-lengthaliasesFor example:
--aliases="10.128.1.0/24;range1:/32"
192.168.100.0/24), a single IP address (e.g.
192.168.100.1), or a netmask in CIDR format (e.g.
/24). If the IP range is specified by CIDR range or single IP
address, it must belong to the CIDR range specified by the range name on the
subnet. If the IP range is specified by netmask, the IP allocator will pick an
available range with the specified netmask and allocate it to this network
interface.
network-attachment--network and --subnet flags.
service-class-idvlan--network-performance-configs=[PROPERTY=VALUE,…]total-egress-bandwidth-tier--network-tier=NETWORK_TIERNETWORK_TIER must be one of:
PREMIUM, STANDARD. The default value is
PREMIUM.
--preemptible--private-ipv6-google-access-type=PRIVATE_IPV6_GOOGLE_ACCESS_TYPEPRIVATE_IPV6_GOOGLE_ACCESS_TYPE must be one of:
enable-bidirectional-access,
enable-outbound-vm-access, inherit-subnetwork.
--private-network-ip=PRIVATE_NETWORK_IP--provisioning-model=PROVISIONING_MODELPROVISIONING_MODEL must be one of:
FLEX_STARTRESERVATION_BOUNDSPOTSTANDARD--request-valid-for-duration=REQUEST_VALID_FOR_DURATIONh, m,
and s for hours, minutes, and seconds, respectively. For example,
specify 30m for a duration of 30 minutes, or 1h2m3s
for 1 hour, 2 minutes, and 3 seconds. Longer durations give you higher chances
that your instance creation request succeeds when resources are in high demand.
--resource-policies=[RESOURCE_POLICY,…]--restart-on-failure--no-restart-on-failure to disable.
--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."
--shielded-secure-boot--shielded-vtpm--[no-]skip-guest-os-shutdown--skip-guest-os-shutdown to enable and
--no-skip-guest-os-shutdown to disable.
--source-instance-template=SOURCE_INSTANCE_TEMPLATE--stack-type=STACK_TYPESTACK_TYPE must be
one of:
IPV4_IPV6IPV4_ONLYIPV6_ONLY--subnet=SUBNET--network is also specified, subnet must be a subnetwork of the
network specified by the --network flag.
--tags=TAG,[TAG,…]gcloud compute
firewall-rules create(1) for more details.
To read more about configuring network tags, read this guide: https://cloud.google.com/vpc/docs/add-remove-network-tags
To list instances with their respective status and tags, run:
gcloud compute instances list --format='table(name,status,tags.list())'
To list instances tagged with a specific tag, tag1, run:
gcloud compute instances list --filter='tags:tag1'--termination-time=TERMINATION_TIME
If neither --termination-time nor --max-run-duration is specified (default), the
VM instance runs until prompted by a user action or system event. If either is
specified, the VM instance is scheduled to be automatically terminated at the
VM's termination timestamp (terminationTimestamp) using the action
specified by --instance-termination-action.
terminationTimestamp is removed whenever the VM is
stopped or suspended and redefined whenever the VM is rerun. For
--termination-time specifically, the terminationTimestamp remains
the same whenever the VM is rerun, but any requests to rerun the VM fail if the
specified timestamp is in the past.
--threads-per-core=THREADS_PER_CORE--visible-core-count=VISIBLE_CORE_COUNT--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:
--address=ADDRESS--no-address--confidential-compute--confidential-compute-type=SEV instead
--confidential-compute-type=CONFIDENTIAL_COMPUTE_TYPECONFIDENTIAL_COMPUTE_TYPE
must be one of:
SEVSEV_SNPTDX--custom-cpu=CUSTOM_CPU
For some machine types, shared-core values can also be used. For example, for E2
machine types, you can specify micro, small, or
medium.
--custom-memory=CUSTOM_MEMORY--custom-extensions--custom-vm-type=CUSTOM_VM_TYPEn1. For more
information about custom machine types, see: https://cloud.google.com/compute/docs/general-purpose-machines#custom_machine_types
--image-project=IMAGE_PROJECTgcloud projects list.
--image=IMAGE$ gcloud compute images
list. It is best practice to use --image when a specific
version of an image is needed.
When using this option,
--boot-disk-device-name and
--boot-disk-size can be used to override
the boot disk's device name and size, respectively.
--image-family=IMAGE_FAMILY--image-family when the latest
version of an image is needed.
By default, debian-12 is assumed for this
flag.
At most one of these can be specified:
--public-ptr--no-public-ptr--public-ptr-domain=PUBLIC_PTR_DOMAIN--no-public-ptr-domain--reservation=RESERVATION--reservation-affinity=specific.
--reservation-affinity=RESERVATION_AFFINITY; default="any"RESERVATION_AFFINITY must be one of:
anynonespecific--scopes=[SCOPE,…]Default
scopes are assigned to all instances. Available aliases are:
DEPRECATION WARNING: https://www.googleapis.com/auth/sqlservice account scope and
Alias URI bigquery https://www.googleapis.com/auth/bigquery cloud-platform https://www.googleapis.com/auth/cloud-platform cloud-source-repos https://www.googleapis.com/auth/source.full_control cloud-source-repos-ro https://www.googleapis.com/auth/source.read_only compute-ro https://www.googleapis.com/auth/compute.readonly compute-rw https://www.googleapis.com/auth/compute datastore https://www.googleapis.com/auth/datastore default https://www.googleapis.com/auth/devstorage.read_only https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/monitoring.write https://www.googleapis.com/auth/pubsub https://www.googleapis.com/auth/service.management.readonly https://www.googleapis.com/auth/servicecontrol https://www.googleapis.com/auth/trace.append gke-default https://www.googleapis.com/auth/devstorage.read_only https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/monitoring https://www.googleapis.com/auth/service.management.readonly https://www.googleapis.com/auth/servicecontrol https://www.googleapis.com/auth/trace.append logging-write https://www.googleapis.com/auth/logging.write monitoring https://www.googleapis.com/auth/monitoring monitoring-read https://www.googleapis.com/auth/monitoring.read monitoring-write https://www.googleapis.com/auth/monitoring.write pubsub https://www.googleapis.com/auth/pubsub service-control https://www.googleapis.com/auth/servicecontrol service-management https://www.googleapis.com/auth/service.management.readonly sql (deprecated) https://www.googleapis.com/auth/sqlservice sql-admin https://www.googleapis.com/auth/sqlservice.admin storage-full https://www.googleapis.com/auth/devstorage.full_control storage-ro https://www.googleapis.com/auth/devstorage.read_only storage-rw https://www.googleapis.com/auth/devstorage.read_write taskqueue https://www.googleapis.com/auth/taskqueue trace https://www.googleapis.com/auth/trace.append userinfo-email https://www.googleapis.com/auth/userinfo.email
sql alias do not provide SQL instance management
capabilities and have been deprecated. Please, use https://www.googleapis.com/auth/sqlservice.admin
or sql-admin to manage your Google SQL Service instances.
--no-scopes--service-account=SERVICE_ACCOUNT--no-service-account--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 create-with-containergcloud beta compute instances create-with-containergcloud preview compute instances create-with-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.