Set the image version in an image family

Linux Windows

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

Set the image version in an image family

Console

  1. In the Google Cloud console, go to theCreate an image page.

    Go to Create an image

  2. Specify theName of your image. For example,image-v1.

  3. 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.

  4. 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.

  5. In theBased on source disk location (default) drop-down list,specify the location to store the image. For example, specifyus tostore the image in theus multi-region, orus-central1 to store it intheus-central1 region. If you do not make a selection,Compute Engine stores the image in the multi-region closest toyour image's source location.

  6. Specify the imageFamily for the new image. For example, addmy-image-family to organize the image as part of animage family.

  7. Optional: specify other image properties:

    • Description: a description for your custom image.
    • Label: alabel to group together resources.
  8. 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.

  9. 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: READY

REST

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: READY

Except 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.