Set the image version in an image family Stay organized with collections Save and categorize content based on your preferences.
Use image families to simplify image versioning. Add an image to an imagefamily to set it as the most recent image version. If you determine that youmust roll back the image family to a previous image version, deprecatethe most recent image in the family.
For best practices when working with image families, seeImage families best practices.
Optionally, you can specify theimage's storage location by using theGoogle Cloud console, thegcloud compute images create commandwith the--storage-location flag, or theimages().insert method.
Before you begin
- Read theImages document.
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
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.- Set a default region and zone.
REST
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:
gcloudinit
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.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
Set the image version in an image family
Console
In the Google Cloud console, go to theCreate an image page.
Specify theName of your image. For example,
image-v1.Specify theSource from which you want to create an image. This canbe a persistent disk, a snapshot, another image, or a disk.raw file inCloud Storage.
If you are creating an image from a disk attached to a running VM,checkKeep instance running to confirm that you want to create theimage while the VM is running. You canprepare your VMbefore creating the image.
In theBased on source disk location (default) drop-down list,specify the location to store the image. For example, specify
ustostore the image in theusmulti-region, orus-central1to store it intheus-central1region. If you do not make a selection,Compute Engine stores the image in the multi-region closest toyour image's source location.Specify the imageFamily for the new image. For example, add
my-image-familyto organize the image as part of animage family.Optional: specify other image properties:
- Description: a description for your custom image.
- Label: alabel to group together resources.
Specify the encryption key. You can choose between a Google-owned and Google-managed encryption key,aCloud Key Management Service (Cloud KMS) key or acustomer-supplied encryption (CSEK)key. If no encryption key is specified, images are encryptedusing a Google-owned and Google-managed encryption key.
ClickCreate to create the image.
gcloud
gcloud compute images create image-v1 \ --source-disk disk-1 \ --source-disk-zone us-central1-f \ --family my-image-family
The image family points toimage-v1. Add a second image to the family:
gcloud compute images create image-v2 \ --source-disk disk-2 \ --source-disk-zone us-central1-f \ --family my-image-family
REST
Make aPOST request to theimages().insert method.Specify the image family in the request body.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/images{ "name": "image-v2", "sourceDisk": "/zones/us-central1-f/disks/disk-2", "family":"my-image-family",}The image family points toimage-v2 because it is the most recent image thatyou added to the image family.
gcloud
You can see which image a family points to by running thegcloud compute images describe-from-family command.
For example:
gcloud compute images describe-from-family my-image-familyfamily: my-image-familyid: '8904691942610171306'kind: compute#imagename: image-v2selfLink: https://compute.googleapis.com/compute/v1/projects/my-project/global/images/image-v2sourceDisk: https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f/disks/disk-v2sourceDiskId: '1677449456001963379'sourceType: RAWstatus: READYREST
Make aGET request to theimages().getFromFamily method.Specify the image family in the request body.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/images/family{ "resourceId":"my-image-family",}If you determine that you must roll back the image family so that it no longerpoints toimage-v2, deprecateimage-v2 and the family will againpoint toimage-v1.
gcloud compute images deprecate image-v2 \ --state DEPRECATED \ --replacement image-v1
Check to make sure that the image family is pointing toimage-v1.
gcloud compute images describe-from-family my-image-familyfamily: my-image-familyid: '2741732787056801255'kind: compute#imagename: image-v1selfLink: https://compute.googleapis.com/compute/v1/projects/my-project/global/images/image-v1sourceDisk: https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f/disks/disk-v1sourceDiskId: '1677449456001963379'sourceType: RAWstatus: READYExcept as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.