验证添加的证明
在这最后一步中,我们将验证证明是否已成功添加到镜像中,并检查其内容。你可以使用 docker buildx imagetools inspect
命令查看镜像的清单,其中包含了任何相关证明的信息。
检查镜像清单的基本语法如下:
docker buildx imagetools inspect <image_tag>
首先,让我们检查使用 --attestation-file
标志创建的 alpine:attested
镜像。
docker buildx imagetools inspect alpine:attested
你应该会看到关于镜像清单的详细输出。查找与“attestations”(证明)相关的部分。你应该能找到一个谓词类型为 https://example.com/attestation/v1
的条目,以及来自 attestation.json
文件的数据。
...
"attestations": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"payload": "...",
"predicateType": "https://example.com/attestation/v1"
}
],
...
现在,让我们检查使用 --predicate-type
标志覆盖谓词类型后创建的 alpine:attested-v2
镜像。
docker buildx imagetools inspect alpine:attested-v2
同样,查找“attestations”部分。这次,你应该会看到一个谓词类型为 https://example.com/another-attestation/v2
的条目,尽管证明数据的内容与之前相同。
...
"attestations": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"payload": "...",
"predicateType": "https://example.com/another-attestation/v2"
}
],
...
这证实了我们已成功将证明添加到 Docker 镜像中,并且可以使用 --predicate-type
标志显式设置谓词类型。
现在,你已经学会了如何准备镜像和证明文件,如何使用 --attestation-file
和 --predicate-type
标志将证明添加到镜像中,以及如何使用 docker buildx imagetools inspect
验证添加的证明。