使用 roxctl CLI 进行镜像扫描

您可以使用 roxctl CLI 扫描存储在远程 registry 和集群本地 registry 中的镜像,包括 Alauda Container Platform 集成镜像仓库中的镜像。

INFO

镜像扫描需要具备访问 registry 和 Central 的相应权限与网络访问能力。

扫描远程集群中的镜像

运行以下命令以扫描指定镜像:

roxctl image scan \
  --image=<image_registry>/<image_name>
  • 对于 <image_registry>,请指定镜像所在的 registry,例如 image-registry.alauda-image-registry.svc:5000/

如果为某个特定集群配置了委派镜像扫描,则可以通过该集群路由扫描请求:

roxctl image scan \
  --image=<image_registry>/<image_name> \
  --cluster=<cluster_name>

示例输出

{
  "Id": "sha256:3f439d7d71adb0a0c8e05257c091236ab00c6343bc44388d091450ff58664bf9",
  "name": {
    "registry": "image-registry.alauda-image-registry.svc:5000",
    "remote": "default/image-stream",
    "tag": "latest",
    "fullName": "image-registry.alauda-image-registry.svc:5000/default/image-stream:latest"
  }
  // ...
}
  • Id:镜像的唯一标识符,可作为完整性和真实性的指纹。
  • name.registry:镜像 registry 位置。
  • name.remote:镜像的远程路径。
  • name.tag:镜像的版本或 tag。
  • name.fullName:镜像的完整名称(registry、路径、tag)。

roxctl image scan 命令选项

选项说明

选项说明
--cluster string将镜像扫描委派给特定集群。
--compact-output以紧凑格式打印 JSON 输出。默认值:false
-f, --force忽略 Central 的扫描缓存,并强制从 Scanner 重新拉取。默认值:false
--headers strings以表格格式打印表头。默认值:COMPONENT, VERSION, CVE, SEVERITY, LINK
--headers-as-comments在 CSV 表格输出中将表头作为注释打印。默认值:false
-h, --help查看 roxctl image scan 命令的帮助文本。
-i, --image string指定要扫描的镜像名称和引用。
-a, --include-snoozed同时返回已 snooze 和未 snooze 的 CVEs。默认值:false
--merge-output合并表格输出中的重复单元格。默认值:true
--no-header不打印表格格式的表头。默认值:false
-o, --output string指定输出格式:tableCSVJSONSARIF
-r, --retries int设置在报错中止前的重试次数。默认值:3
-d, --retry-delay int设置重试之间等待的秒数。默认值:3
--row-jsonpath-expressions string使用 JSON path 表达式从 JSON 对象创建行。有关详细信息,请参见 roxctl image scan --help

相关工作流