首页 > 解决方案 > GCP - 如何使用 gcloud 过滤引导磁盘?

问题描述

我正在尝试gcloud compute instances list在一个项目上运行,并且只获取使用特定启动磁盘或映像的实例列表。我目前正在运行的是:

gcloud compute instances list --project=my-project --filter="disks.initializeParams.sourceImage='image-name'"

但是,这将返回 0 个项目,而且我遇到的任何过滤器 initializeParams 都会返回 0 个项目。我的过滤有问题吗?或者有没有更好的方法来获取使用特定图像的实例列表?

标签: google-cloud-platformgoogle-compute-enginegcloud

解决方案


仅使用gcloud

gcloud compute disks list \
--project=${PROJECT} \
--format="value(users[].basename(),sourceImage.scope())"

推荐阅读