docker scout 比较

DescriptionCompare two images and display differences (experimental)
Usagedocker scout compare --to IMAGE|DIRECTORY|ARCHIVE [IMAGE|DIRECTORY|ARCHIVE]
Aliases
docker scout diff

实验性

此命令是实验性的。

实验性功能旨在用于测试和反馈,因为它们的功能或设计可能会在版本之间更改而不发出警告,或者可能在未来的版本中完全移除。

描述

docker scout compare 命令分析两个镜像并显示比较结果。

此命令是实验性的,其行为在未来可能会发生变化

此命令的预期用途是比较同一图像的两个版本。例如,当构建新图像并与生产环境中运行的版本进行比较时。

如果没有指定图像,则使用最近构建的图像作为比较目标。

支持以下工件类型:

  • 图片
  • OCI 布局目录
  • Tarball 归档文件,由 docker save 创建
  • 本地目录或文件

默认情况下,该工具期望一个图像引用,例如:

  • redis
  • curlimages/curl:7.87.0
  • mcr.microsoft.com/dotnet/runtime:7.0

如果您想要分析的工件是一个OCI目录、一个tarball归档文件、一个本地文件或目录,或者如果您想要控制镜像的解析来源,您必须在引用前加上以下前缀之一:

  • image://(默认)使用本地镜像,或回退到注册表查找
  • local:// 使用本地镜像存储中的镜像(不进行注册表查找)
  • registry:// 使用来自注册表的镜像(不要使用本地镜像)
  • oci-dir:// 使用一个OCI布局目录
  • archive:// 使用由 docker save 创建的 tarball 归档文件
  • fs:// 使用本地目录或文件
  • sbom:// SPDX 文件或带有 SPDX 谓词的 in-toto 证明文件或 syft json SBOM 文件

选项

OptionDefaultDescription
-x, --exit-onComma separated list of conditions to fail the action step if worse, options are: vulnerability, policy
--formattextOutput format of the generated vulnerability report:
- text: default output, plain text with or without colors depending on the terminal
- markdown: Markdown output
--hide-policiesHide policy status from the output
--ignore-baseFilter out CVEs introduced from base image
--ignore-unchangedFilter out unchanged packages
--multi-stageShow packages from multi-stage Docker builds
--only-fixedFilter to fixable CVEs
--only-package-typeComma separated list of package types (like apk, deb, rpm, npm, pypi, golang, etc)
--only-policyComma separated list of policies to evaluate
--only-severityComma separated list of severities (critical, high, medium, low, unspecified) to filter CVEs by
--only-stageComma separated list of multi-stage Docker build stage names
--only-unfixedFilter to unfixed CVEs
--orgNamespace of the Docker organization
-o, --outputWrite the report to a file
--platformPlatform of image to analyze
--refReference to use if the provided tarball contains multiple references.
Can only be used with archive
--toImage, directory, or archive to compare to
--to-envName of environment to compare to
--to-latestLatest image processed to compare to
--to-refReference to use if the provided tarball contains multiple references.
Can only be used with archive.

示例

比较最近构建的镜像与最新标签

$ docker scout compare --to namespace/repo:latest

比较本地构建与注册表中的相同标签

$ docker scout compare local://namespace/repo:latest --to registry://namespace/repo:latest

忽略基础镜像

$ docker scout compare --ignore-base --to namespace/repo:latest namespace/repo:v1.2.3-pre

生成一个Markdown输出

$ docker scout compare --format markdown --to namespace/repo:latest namespace/repo:v1.2.3-pre

仅比较Maven包并仅显示Maven包的关键漏洞

$ docker scout compare --only-package-type maven --only-severity critical --to namespace/repo:latest namespace/repo:v1.2.3-pre

显示两张图像的所有策略结果

docker scout compare --to namespace/repo:latest namespace/repo:v1.2.3-pre