您只能删除您或有权访问相应项目的人添加的自定义映像。
如果您想保留映像的备份,请先将自定义映像导出到 Cloud Storage,然后再将其删除。
准备工作
- 阅读映像文档。
-
如果您尚未设置身份验证,请进行设置。身份验证是通过其进行身份验证以访问 Trusted Cloud by S3NS 服务和 API 的过程。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 Compute Engine 进行身份验证:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, sign in to the gcloud CLI with your federated identity and then initialize it by running the following command:
gcloud init
- Set a default region and zone.
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
Create local authentication credentials for your user account:
gcloud auth application-default login
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.
在 Trusted Cloud 控制台中,前往映像页面。
选中您想要删除的映像左侧的框。
点击页面顶部的删除。您的映像已删除。
PROJECT_ID
:映像所属的项目。RESOURCE_ID
:要删除的映像的名称。
Python
如需在本地开发环境中使用本页面上的 Python 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭证设置应用默认凭证。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
REST
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭据。
After installing the Google Cloud CLI, sign in to the gcloud CLI with your federated identity and then initialize it by running the following command:
gcloud init
如需了解详情,请参阅 Trusted 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
请替换以下内容:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-24。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-24。"],[[["Custom images can only be deleted by the user who created them or someone with project access, and this action is irreversible, so exporting a backup to Cloud Storage beforehand is recommended."],["Before deleting an image, it is recommended to read the Images document and set up authentication, which varies depending on whether you're using the Console, gcloud CLI, Python, or REST API."],["Deleting an image can be done through the Google Cloud console by navigating to the **Images** page, selecting the image, and clicking **Delete**, or through the `gcloud compute images delete` command in the gcloud CLI."],["The provided code samples demonstrate how to programmatically delete images using Go, Java, and Python, including the necessary steps for setting up the environment and handling potential errors."],["To delete an image using the REST API, you need to make a `POST` request to the `images().delete` method, specifying the project ID and the name of the image you want to delete."]]],[]] -