You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询:如何用OCI CLI仅显示自定义镜像及列表不全问题

解决OCI CLI仅显示自定义镜像并加载全部结果的问题

1. 修正基础命令,确保拉取全部镜像

你当前的命令缺少** compartment ID **的具体值,--compartment(或简写-c)参数必须指定目标 compartment 的 OCID,否则CLI可能仅查询默认根 compartment 或返回分页第一页结果。正确的基础命令格式为:

oci compute image list --compartment-id <你的compartment OCID> --all

--all参数会自动处理分页逻辑,拉取所有符合条件的镜像,而非仅返回第一页数据。

2. 过滤仅显示自定义镜像

OCI中自定义镜像与官方/市场镜像的核心区分字段是source-type:

  • Oracle官方镜像的source-type为oracle
  • 市场镜像的source-type为marketplace
  • 自定义镜像的source-type通常为image或boot-volume(取决于镜像创建来源)

你可以通过两种方式实现过滤:

方式一:CLI层面直接过滤(使用--filter参数)

oci compute image list --compartment-id <你的compartment OCID> --all --filter '{"source-type": ["image", "boot-volume"]}'

方式二:结果层面精准筛选(使用--query参数)

如果需要排除所有官方/市场镜像,可借助JMESPath查询语法实现更灵活的过滤:

oci compute image list --compartment-id <你的compartment OCID> --all --query 'data[?!contains(["oracle", "marketplace"], source-type)]'

额外排查点

  • 确认CLI配置的用户权限与控制台一致:若控制台能看到所有镜像,CLI使用的~/.oci/config配置文件对应的用户必须拥有目标compartment下compute-images:list的权限。
  • 若自定义镜像分布在多个子compartment,需添加--compartment-id-in-subtree true参数拉取所有子compartment的镜像:
oci compute image list --compartment-id <根compartment OCID> --all --compartment-id-in-subtree true --query 'data[?!contains(["oracle", "marketplace"], source-type)]'

内容的提问来源于stack exchange,提问作者raindrop

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 13:52:04