Stay organized with collections Save and categorize content based on your preferences.
Use a machine image to store all the configuration, metadata, permissions, and data from multiple disks for a VM instance running on Compute Engine. The VM instance that you use to create a machine image is referred to as a source VM instance.
For information about when and how to use machine images, see Machine images.
This document describes the steps for creating a machine image from a source VM instance.
Before you beginSelect the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
You can't create machine images from source VMs that:
z3-highmem-192-highlssd-metal
.When you create machine images from VM instances or create VM instances from machine images, the following instance and disk properties are not preserved or restored:
disks.architecture
disks.description
disks.labels
disks.locked
disks.multiWriter
disks.onUpdateAction
disks.provisionedIops
disks.shieldedInstanceInitialState
disks.sourceImage
disks.sourceImageEncryptionKey
disks.sourceInstantSnapshot
disks.sourceSnapshot
disks.sourceSnapshotEncryptionKey
privateIpv6GoogleAccess
resourceManagerTags
resourcePolicies
secure_tag
shieldedInstanceConfig
To perform this task, you must have the following permissions:
compute.machineImages.create
on the projectcompute.instances.useReadOnly
on the source instancecompute.disks.createSnapshot
on the diskYou can create machine images using either the Google Cloud console, the Google Cloud CLI, or REST.
To create a machine image, you need the following information:
storageLocation
. If you don't specify a location, the default storage location is the multiregional Cloud Storage location of the source VM instance.If you want to use a machine image for instance cloning and snapshotting, remove the OS and app information that is unique to the instance before generating the machine image from an instance. For example, for Windows VM instances, use GCESysprep
to prepare the system for replication.
In the Google Cloud console, go to the Machine images page.
Click Create Machine image.
Specify a Name for your machine image.
Optional: Provide a Description.
Select the Source VM instance.
Optional: Specify where to store the machine image. Choose between Multi-regional or Regional storage. For more information about location, see Machine image storage location.
Optional: Select an Encryption method.
Click Create.
Use the gcloud compute machine-images create
command to create a machine image from an instance.
gcloud compute machine-images create MACHINE_IMAGE_NAME \ --source-instance=SOURCE_VM_NAME
Replace the following:
MACHINE_IMAGE_NAME
: name of the machine image that you want to create.SOURCE_VM_NAME
: name of the source VM instance that you want to create the image from.Example
For example, you can use the following gcloud
command to create a machine image called my-machine-image
from a source instance called my-instance
:
gcloud compute machine-images create my-machine-image \ --source-instance=my-instance
The process takes a few minutes. When the machine image is created, you get an output that resembles the following:
Created [https://www.googleapis.com/compute/v1/projects/project-12345/global/machineImages/my-machine-image]. NAME STATUS my-machine-image READYREST
In the API, construct a POST
request to the machineimages.insert
method. In the request body, include the following POST
request:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/machineImages { "name": "MACHINE_IMAGE_NAME", "sourceInstance": "SOURCE_INSTANCE_URL" }
Replace the following:
PROJECT_ID
: project ID.MACHINE_IMAGE_NAME
: name of the machine image that you want to create.SOURCE_INSTANCE_URL
: full or partial URL of the source VM instance that you want to use to create the machine image. For example, if you have a source instance called my-instance
in a project called myProject
. The following URLs are valid:
https://www.googleapis.com/compute/v1/projects/myProject/global/instances/my-instance
projects/myProject/global/instances/my-instance
global/instances/my-instance
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 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Machine images store a VM instance's configuration, metadata, permissions, and data from multiple disks, using a source VM instance as the base."],["Machine images can be created through the Google Cloud console, the Google Cloud CLI, or REST API, requiring specific permissions such as `compute.machineImages.create`."],["Creating a machine image involves specifying a name, the source VM instance, and its zone, with optional settings like storage location and encryption key, with a limit of six creations per instance every 60 minutes."],["Certain instance and disk properties are not preserved or restored when creating or using machine images, such as `disks.architecture`, `disks.description`, and `resourcePolicies`, among others."],["Machine images can not be created from source VMs that exceed 200TB of disks, have no attached disks, any attached Hyperdisk volumes or use a C3D, H3, A3 or Z3 machine type."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4