Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Linux
Windows
Gunakan kelompok image untuk menyederhanakan pembuatan versi image. Tambahkan gambar ke kelompok
gambar untuk menetapkannya sebagai versi gambar terbaru. Jika Anda memutuskan bahwa Anda
harus melakukan roll back kelompok image ke versi image sebelumnya, hentikan
penggunaan image terbaru dalam kelompok tersebut.
Jika Anda belum melakukannya, siapkan autentikasi.
Autentikasi adalah
proses yang digunakan untuk memverifikasi identitas Anda untuk mengakses Google Cloud layanan dan API.
Untuk menjalankan kode atau sampel dari lingkungan pengembangan lokal, Anda dapat melakukan autentikasi ke
Compute Engine dengan memilih salah satu opsi berikut:
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
Menginstal Google Cloud CLI.
Setelah penginstalan,
lakukan inisialisasi Google Cloud CLI dengan menjalankan perintah berikut:
Tentukan Sumber tempat Anda ingin membuat image. Hal ini dapat berupa persistent disk, snapshot, image lain, atau file disk.raw di Cloud Storage.
Jika Anda membuat image dari disk yang terpasang ke VM yang sedang berjalan, centang Tetap jalankan instance untuk mengonfirmasi bahwa Anda ingin membuat image saat VM sedang berjalan. Anda dapat menyiapkan VM
sebelum membuat image.
Di menu drop-down Berdasarkan lokasi disk sumber (default),
tentukan lokasi untuk menyimpan gambar. Misalnya, tentukan us untuk menyimpan image di multi-region us, atau us-central1 untuk menyimpannya di region us-central1. Jika Anda tidak menentukan pilihan, Compute Engine akan menyimpan image di multi-region yang paling dekat dengan lokasi sumber image Anda.
Tentukan Keluarga image untuk image baru. Misalnya, tambahkan
my-image-family untuk mengatur image sebagai bagian dari
kelompok image.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/images/family
{
"resourceId":"my-image-family",
}
Jika Anda memutuskan bahwa Anda harus melakukan roll back kelompok image agar tidak lagi
menunjuk ke image-v2, hentikan penggunaan image-v2 dan kelompok tersebut akan kembali
menunjuk ke image-v1.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[[["\u003cp\u003eImage families simplify image versioning by allowing you to group related images and designate the most recent version.\u003c/p\u003e\n"],["\u003cp\u003eAdding a new image to an existing image family automatically sets it as the newest version within that family.\u003c/p\u003e\n"],["\u003cp\u003eYou can manage the storage location of an image during creation using the Google Cloud console, the \u003ccode\u003egcloud compute images create\u003c/code\u003e command, or the \u003ccode\u003eimages().insert\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eRolling back to a previous image version involves deprecating the most recent image, which then reverts the family's pointer to the prior version.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud compute images describe-from-family\u003c/code\u003e command or the \u003ccode\u003eimages().getFromFamily\u003c/code\u003e method allows you to confirm which image a specific image family currently references.\u003c/p\u003e\n"]]],[],null,["# Set the image version in an image family\n\nLinux Windows\n\n*** ** * ** ***\n\nUse image families to simplify image versioning. Add an image to an image\nfamily to set it as the most recent image version. If you determine that you\nmust roll back the image family to a previous image version, deprecate\nthe most recent image in the family.\n\nFor best practices when working with image families, see\n[Image families best practices](/compute/docs/images/image-families-best-practices).\n\nOptionally, you can specify the\n[image's storage location](#selecting_image_storage_location) by using the\nGoogle Cloud console, the\n[`gcloud compute images create` command](/sdk/gcloud/reference/compute/images/create)\nwith the `--storage-location` flag, or the\n[`images().insert` method](/compute/docs/reference/rest/v1/images/insert).\n\nBefore you begin\n----------------\n\n- Read the [Images](/compute/docs/images) document.\n- If you haven't already, set up [authentication](/compute/docs/authentication). 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:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nSet the image version in an image family\n----------------------------------------\n\n### Console\n\n1. In the Google Cloud console, go to the **Create an image** page.\n\n [Go to Create an image](https://console.cloud.google.com/compute/imagesAdd)\n2. Specify the **Name** of your image. For example, `image-v1`.\n\n3. Specify the **Source** from which you want to create an image. This can\n be a persistent disk, a snapshot, another image, or a disk.raw file in\n Cloud Storage.\n\n4. If you are creating an image from a disk attached to a running VM,\n check **Keep instance running** to confirm that you want to create the\n image while the VM is running. You can [prepare your VM](#prepare_instance_for_image)\n before creating the image.\n\n5. In the **Based on source disk location (default)** drop-down list,\n specify the location to store the image. For example, specify `us` to\n store the image in the `us` multi-region, or `us-central1` to store it in\n the `us-central1` region. If you do not make a selection,\n Compute Engine stores the image in the multi-region closest to\n your image's source location.\n\n6. Specify the image **Family** for the new image. For example, add\n `my-image-family` to organize the image as part of an\n [image family](/compute/docs/images#image_families).\n\n7. Optional: specify other image properties:\n\n - **Description**: a description for your custom image.\n - **Label** : a [label](/compute/docs/labeling-resources) to group together resources.\n8. Specify the encryption key. You can choose between a Google-owned and Google-managed encryption key,\n a [Cloud Key Management Service (Cloud KMS)](/kms/docs) key or a [customer-\n supplied encryption (CSEK)](/compute/docs/disks/customer-supplied-encryption)\n key. If no encryption key is specified, images are encrypted\n using a Google-owned and Google-managed encryption key.\n\n9. Click **Create** to create the image.\n\n### gcloud\n\n```\ngcloud compute images create image-v1 \\\n --source-disk disk-1 \\\n --source-disk-zone us-central1-f \\\n --family my-image-family\n```\n\nThe image family points to `image-v1`. Add a second image to the family: \n\n```\ngcloud compute images create image-v2 \\\n --source-disk disk-2 \\\n --source-disk-zone us-central1-f \\\n --family my-image-family\n```\n\n### REST\n\nMake a `POST` request to the\n[`images().insert` method](/compute/docs/reference/v1/images/insert).\nSpecify the image family in the request body. \n\n```\nPOST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/images\n\n{\n \"name\": \"image-v2\",\n \"sourceDisk\": \"/zones/us-central1-f/disks/disk-2\",\n \"family\":\"my-image-family\",\n\n}\n```\n\nThe image family points to `image-v2` because it is the most recent image that\nyou added to the image family. \n\n### gcloud\n\nYou can see which image a family points to by running the\n[`gcloud compute images describe-from-family` command](/sdk/gcloud/reference/compute/images/describe-from-family).\n\nFor example: \n\n```\ngcloud compute images describe-from-family my-image-family\n\nfamily: my-image-family\nid: '8904691942610171306'\nkind: compute#image\nname: image-v2\nselfLink: https://compute.googleapis.com/compute/v1/projects/my-project/global/images/image-v2\nsourceDisk: https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f/disks/disk-v2\nsourceDiskId: '1677449456001963379'\nsourceType: RAW\nstatus: READY\n```\n\n### REST\n\nMake a `GET` request to the\n[`images().getFromFamily` method](/compute/docs/reference/rest/v1/images/getFromFamily).\nSpecify the image family in the request body. \n\n```\nGET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/images/family\n\n{\n \"resourceId\":\"my-image-family\",\n\n}\n```\n\nIf you determine that you must roll back the image family so that it no longer\npoints to `image-v2`, deprecate `image-v2` and the family will again\npoint to `image-v1`. \n\n```\ngcloud compute images deprecate image-v2 \\\n --state DEPRECATED \\\n --replacement image-v1\n```\n\nCheck to make sure that the image family is pointing to `image-v1`. \n\n```\ngcloud compute images describe-from-family my-image-family\n\nfamily: my-image-family\nid: '2741732787056801255'\nkind: compute#image\nname: image-v1\nselfLink: https://compute.googleapis.com/compute/v1/projects/my-project/global/images/image-v1\nsourceDisk: https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f/disks/disk-v1\nsourceDiskId: '1677449456001963379'\nsourceType: RAW\nstatus: READY\n\n```"]]