docker scout 比较
| Description | Compare two images and display differences (experimental) |
|---|---|
| Usage | docker scout compare --to IMAGE|DIRECTORY|ARCHIVE [IMAGE|DIRECTORY|ARCHIVE] |
| Aliases | docker scout diff |
实验性
此命令是实验性的。
实验性功能旨在用于测试和反馈,因为它们的功能或设计可能会在版本之间更改而不发出警告,或者可能在未来的版本中完全移除。
描述
docker scout compare 命令分析两个镜像并显示比较结果。
此命令是实验性的,其行为在未来可能会发生变化
此命令的预期用途是比较同一图像的两个版本。例如,当构建新图像并与生产环境中运行的版本进行比较时。
如果没有指定图像,则使用最近构建的图像作为比较目标。
支持以下工件类型:
- 图片
- OCI 布局目录
- Tarball 归档文件,由
docker save创建 - 本地目录或文件
默认情况下,该工具期望一个图像引用,例如:
rediscurlimages/curl:7.87.0mcr.microsoft.com/dotnet/runtime:7.0
如果您想要分析的工件是一个OCI目录、一个tarball归档文件、一个本地文件或目录,或者如果您想要控制镜像的解析来源,您必须在引用前加上以下前缀之一:
image://(默认)使用本地镜像,或回退到注册表查找local://使用本地镜像存储中的镜像(不进行注册表查找)registry://使用来自注册表的镜像(不要使用本地镜像)oci-dir://使用一个OCI布局目录archive://使用由docker save创建的 tarball 归档文件fs://使用本地目录或文件sbom://SPDX 文件或带有 SPDX 谓词的 in-toto 证明文件或syftjson SBOM 文件
选项
| Option | Default | Description |
|---|---|---|
-x, --exit-on | Comma separated list of conditions to fail the action step if worse, options are: vulnerability, policy | |
--format | text | Output format of the generated vulnerability report: - text: default output, plain text with or without colors depending on the terminal - markdown: Markdown output |
--hide-policies | Hide policy status from the output | |
--ignore-base | Filter out CVEs introduced from base image | |
--ignore-unchanged | Filter out unchanged packages | |
--multi-stage | Show packages from multi-stage Docker builds | |
--only-fixed | Filter to fixable CVEs | |
--only-package-type | Comma separated list of package types (like apk, deb, rpm, npm, pypi, golang, etc) | |
--only-policy | Comma separated list of policies to evaluate | |
--only-severity | Comma separated list of severities (critical, high, medium, low, unspecified) to filter CVEs by | |
--only-stage | Comma separated list of multi-stage Docker build stage names | |
--only-unfixed | Filter to unfixed CVEs | |
--org | Namespace of the Docker organization | |
-o, --output | Write the report to a file | |
--platform | Platform of image to analyze | |
--ref | Reference to use if the provided tarball contains multiple references. Can only be used with archive | |
--to | Image, directory, or archive to compare to | |
--to-env | Name of environment to compare to | |
--to-latest | Latest image processed to compare to | |
--to-ref | Reference 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