您只能删除您或有权访问相应项目的人添加的自定义映像。
如果您想保留映像的备份,请先将自定义映像导出到 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 控制台中,前往映像页面。
选中您想要删除的映像左侧的框。
点击页面顶部的删除。您的映像已删除。
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, 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
请替换以下内容:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-09。
-