Sub topic 9
Inspecting SBOM and provenance of a pushed image
This chapter assumes you can push an image built with --sbom=true and --provenance=mode=max, you know what an image index and a digest are, and you can read JSON with jq. You will read the attestations back from the registry and check that they describe the image you built.
Why inspect the registry copy
Reading attestations from the pushed image tests the real result. The registry holds the index, the image manifests, and the attestation manifests. Anyone who pulls the tag sees exactly that. If an attestation is missing there, the registry or the push step dropped it, and your local build output won't show that.
Read the SBOM
Build and push the example image first. This repeats the earlier command.
docker buildx build \
--sbom=true \
--provenance=mode=max \
--tag registry.example.com/demo/app:1.0 \
--push .Then ask imagetools for the SBOM as JSON:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}'The raw output is long. Pipe it through jq to read it:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' | jq .For a single-platform image, the SBOM sits under an SPDX key. It is an SPDX document. Its packages array lists what the scanner found, for the example Dockerfile that includes curl and its libraries. To list only names and versions:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' \
| jq -r '.SPDX.packages[] | "\(.name) \(.versionInfo)"'Read the provenance
The provenance uses the same pattern with a different field:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}'The SLSA statement sits under an SLSA key. It records the builder, the build type, the invocation (parameters such as build arguments), and the materials, which are the base images and other inputs. In max mode it also records the full build configuration, including the Dockerfile steps.
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}' | jq '.SLSA | keys'The exact field names depend on the Buildx version and the SLSA version it emits. Print the keys first, then pick fields.
What to check
- The SBOM lists the packages you expect, such as
curlfrom the example Dockerfile. - The provenance materials show the base image you meant to use, for example
alpine:3.20, with its digest. - The provenance does not contain secrets.
maxmode can expose build arguments and Dockerfile contents, so review it before you push to a public registry.
Common problems
| Symptom | Likely cause |
|---|---|
| `.SBOM` or `.Provenance` prints `null` or nothing | The image was built without attestations, or the build was not pushed. |
| Attestations vanish after a copy or retag | The copy tool copied only the image manifest, not the whole index. |
| `jq` path errors | The image is multi-platform and the JSON is keyed by platform. |
| Pull fails in an old tool | The tool cannot handle the extra manifests in the index. |
The last case is why --provenance=false exists. It builds an image without the extra manifests:
docker buildx build \
--provenance=false \
--tag demo/app:no-provenance \
--push .Use it only when a consumer needs it. It removes information that others may rely on.
Exercise
You run docker buildx imagetools inspect registry.example.com/demo/app:1.0 --format '{{ json .SBOM }}' and get an empty result, although you built with --sbom=true. Name two things to check.
Show answer
Check that the build used --push, so the attestation reached the registry. Also check that the image was not later copied or retagged with a tool that dropped the attestation manifests. A different registry or driver that does not support them is another possibility.