gcloud compute instances create
NAME
NAME
…]--boot-disk-device-name
BOOT_DISK_DEVICE_NAME
]--boot-disk-size
BOOT_DISK_SIZE
]--boot-disk-type
BOOT_DISK_TYPE
]--can-ip-forward
]--description
DESCRIPTION
]--disk
PROPERTY
=VALUE
[PROPERTY
=VALUE
…]]--format
FORMAT
]--help
]--image
IMAGE
| centos-6
| centos-7
| container-vm
| coreos
| debian-7
| debian-7-backports
| opensuse-13
| rhel-6
| rhel-7
| sles-11
| ubuntu-12-04
| ubuntu-14-04
| ubuntu-14-10
]--image-project
IMAGE_PROJECT
]--local-ssd
[PROPERTY
=VALUE
…]]--machine-type
MACHINE_TYPE
; default="n1-standard-1"]--maintenance-policy
MAINTENANCE_POLICY
]--metadata
KEY
=VALUE
[KEY
=VALUE
…]]--metadata-from-file
KEY
=LOCAL_FILE_PATH
[KEY
=LOCAL_FILE_PATH
…]]--network
NETWORK
; default="default"]--address
ADDRESS
| --no-address
]--no-boot-disk-auto-delete
]--no-restart-on-failure
]--project
PROJECT_ID
]--quiet
, -q
]--no-scopes
| --scopes
SCOPE
[[ACCOUNT
=]SCOPE
…]]--tags
TAG
[TAG
…]]--zone
ZONE
]-h
]gcloud compute instances create
facilitates the creation of Google Compute Engine
virtual machines. For example, running:$ gcloud compute instances create example-instance-1 \ example-instance-2 example-instance-3 --zone us-central1-a
example-instance-1
,
example-instance-2
, and example-instance-3
in the
us-central1-a
zone.EXAMPLES
section below.NAME
[NAME
…]
--address
ADDRESS
--boot-disk-device-name
BOOT_DISK_DEVICE_NAME
--boot-disk-size
BOOT_DISK_SIZE
KB
for kilobyte, MB
for megabyte, GB
for gigabyte,
or TB
for terabyte. For example, 10GB
will produce a 10 gigabyte
disk. If omitted, a default size of 200 GB is used. The minimum size a
boot disk can have is 10 GB. Disk size must be a multiple of 1 GB.
--boot-disk-type
BOOT_DISK_TYPE
$ gcloud compute disk-types list
.
--can-ip-forward
--description
DESCRIPTION
--disk
PROPERTY
=VALUE
[PROPERTY
=VALUE
…]
name
mode
below).
mode
ro
for read-only and rw
for read-write. If
omitted, rw
is used as a default. It is an error for mode
to be rw
when creating more than one instance because
read-write disks can only be attached to a single instance.
boot
yes
, indicates that this is a boot disk. The
virtual machines will use the first partition of the disk for
their root file systems. The default value for this is no
.
device-name
persistent-disk-N
will be used.
auto-delete
yes
, 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 no
.
--image
IMAGE
| centos-6
| centos-7
| container-vm
| coreos
| debian-7
| debian-7-backports
| opensuse-13
| rhel-6
| rhel-7
| sles-11
| ubuntu-12-04
| ubuntu-14-04
| ubuntu-14-10
Alias | Project | Image Name |
---|---|---|
centos-6 | centos-cloud | centos-6 |
centos-7 | centos-cloud | centos-7 |
container-vm | google-containers | container-vm |
coreos | coreos-cloud | coreos-stable |
debian-7 | debian-cloud | debian-7-wheezy |
debian-7-backports | debian-cloud | backports-debian-7-wheezy |
opensuse-13 | opensuse-cloud | opensuse-13 |
rhel-6 | rhel-cloud | rhel-6 |
rhel-7 | rhel-cloud | rhel-7 |
sles-11 | suse-cloud | sles-11 |
ubuntu-12-04 | ubuntu-os-cloud | ubuntu-1204-precise |
ubuntu-14-04 | ubuntu-os-cloud | ubuntu-1404-trusty |
ubuntu-14-10 | ubuntu-os-cloud | ubuntu-1410-utopic |
--image-project
. When --image-project
is
present, no API calls are made to resolve the image. This
property is useful for scripts.--boot-disk-device-name
and
--boot-disk-size
can be used to override the boot disk’s
device name and size, respectively.debian-7-backports
is assumed for this flag.--image-project
IMAGE_PROJECT
--image
for more details.
--local-ssd
[PROPERTY
=VALUE
…]
device-name
local-ssd-N
will be used.
interface
SCSI
and NVME
. SCSI is
the default and is supported by more guest operating systems. NVME
may provide higher performance.
--machine-type
MACHINE_TYPE
; default="n1-standard-1"
gcloud compute
machine-types list
.
--maintenance-policy
MAINTENANCE_POLICY
TERMINATE
indicates that the instances
should be terminated. MIGRATE
indicates that the instances
should be migrated to a new host. Choosing MIGRATE
will
temporarily impact the performance of instances during a
migration event. If omitted, MIGRATE
is assumed.
--metadata
KEY
=VALUE
[KEY
=VALUE
…]
_--metadata key-1=value-1
key-2=value-2 key-3=value-3_
.
startup-script
--metadata-from-file
can be used to pull the value from a
file.
startup-script-url
startup-script
except that
the script contents are pulled from a publicly-accessible
location on the web.
--metadata-from-file
KEY
=LOCAL_FILE_PATH
[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.
--network
NETWORK
; default="default"
default
network is used.
--no-address
--no-boot-disk-auto-delete
--no-restart-on-failure
--no-scopes
--scopes
SCOPE
[[ACCOUNT
=]SCOPE
…]
default
. Example:
$ gcloud compute instances create example-instance --scopes compute-rw \ me@project.gserviceaccount.com=storage-rw
storage-ro
scope is
added to the instances. To create instances with no scopes,
use --no-scopes
:$ gcloud compute instances create example-instance --no-scopes
Alias | URI |
---|---|
bigquery | https://www.googleapis.com/auth/bigquery |
compute-ro | https://www.googleapis.com/auth/compute.readonly |
compute-rw | https://www.googleapis.com/auth/compute |
datastore | https://www.googleapis.com/auth/datastore |
sql | 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 |
userinfo-email | https://www.googleapis.com/auth/userinfo.email |
--tags
TAG
[TAG
…]
gcloud compute firewall-rules create
(1) for more
details.
--zone
ZONE
compute/zone
property:$ gcloud config set compute/zone ZONE
$ gcloud compute zones list
$ gcloud config unset compute/zone
CLOUDSDK_COMPUTE_ZONE
.--format
FORMAT
json
, text
, yaml
.
--help
--project
PROJECT_ID
--quiet
, -q
-h
_Red Hat Enterprise Linux
6_
image available, run:$ gcloud compute instances create example-instance --image rhel-6 \ --zone us-central1-a
compute
component. See
installing components
if it is not installed.