您只能刪除由您或擁有專案存取權限的人所新增的自訂圖片。
如果您想保留映像檔的備份,請先將自訂映像檔匯出至 Cloud Storage,再刪除映像檔。
事前準備
- 參閱「圖片」說明文件。
-
如果尚未設定,請先設定驗證機制。「驗證」是指驗證身分,以便存取 Google Cloud 服務和 API 的程序。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,以便對 Compute Engine 進行驗證:
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
-
After installing the Google Cloud CLI, initialize it 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.
- Set a default region and zone.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
前往 Google Cloud 控制台的「Images」頁面。
找到您要刪除的映像檔,並勾選該映像檔左側的方塊。
按一下頁面頂端的 [Delete] (刪除),即可刪除映像檔。
PROJECT_ID
:圖片所屬的專案。RESOURCE_ID
:要刪除的映像檔名稱。
Python
如要在本機開發環境中使用本頁面上的 Python 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it 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.
詳情請參閱 Google Cloud 驗證說明文件中的「驗證以使用 REST」。
刪除自訂映像檔
請使用下列其中一種方法刪除圖片。
主控台
gcloud
使用
gcloud compute images delete
指令刪除圖片:gcloud compute images delete IMAGE_NAME
將
IMAGE_NAME
替換為要刪除的圖片名稱。Go
Java
Python
REST
對
images().delete
方法提出POST
要求。指定要刪除的映像檔名稱。POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/images/RESOURCE_ID
更改下列內容:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-06-19 (世界標準時間)。
-