您只能刪除由您或擁有專案存取權限的人所新增的自訂圖片。
如果您想保留映像檔的備份,請先將自訂映像檔匯出至 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.
Python
To use the Python samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- 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.
For more information, see Set up authentication for a local development environment.
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.
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.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
刪除自訂映像檔
請使用下列其中一種方法刪除圖片。
主控台
前往 Google Cloud 控制台的「Images」頁面。
找到您要刪除的映像檔,並勾選該映像檔左側的方塊。
按一下頁面頂端的 [Delete] (刪除),即可刪除映像檔。
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
更改下列內容:
PROJECT_ID
:圖片所屬的專案。RESOURCE_ID
:要刪除的映像檔名稱。