Sub topic 2
BuildKit and Buildx: Where Attestations Are Produced
Assume you can write a Dockerfile, push images to a registry, and read basic JSON. BuildKit creates the image and its build metadata. Buildx is the Docker CLI plugin that selects and controls a BuildKit builder.
Generate attestations during the build
An SBOM (Software Bill of Materials) lists software packages found in the image. Provenance records how, where, and from which inputs the image was built. BuildKit produces both as attestations while it solves the Dockerfile.
FROM alpine:3.20
RUN apk add --no-cache curl
CMD ["curl", "--version"]Enable both attestations when building and pushing:
docker buildx build \
--sbom=true \
--provenance=mode=max \
--tag registry.example.com/demo/app:1.0 \
--push .The --attest form makes the types explicit:
docker buildx build \
--attest type=sbom \
--attest type=provenance,mode=min \
--tag registry.example.com/demo/app:1.0 \
--push .The --push option matters. It exports the image and its attestations to the registry instead of loading only the runnable image into the local Docker image store.
Builder drivers and registries
A Buildx builder uses a driver to run BuildKit. The docker-container driver runs BuildKit in a dedicated container and is a practical choice when you need consistent attestation support.
docker buildx create --name attested-builder \
--driver docker-container --use
docker buildx inspect --bootstrapThe registry must preserve OCI image indexes and attached attestation manifests. A registry or export method that understands only a single image manifest may discard or hide this metadata. Test the complete path with the same registry used by deployment.
How storage works
For a multi-platform image, the registry stores an image index containing platform-specific image manifests. BuildKit adds attestation manifests beside those image manifests. The attestations refer to the image they describe, so clients can retrieve them without changing the image filesystem.
Exercise
Why should an attested image normally be pushed to a registry instead of exported with docker save?
Show answer
The registry can preserve the image index and its attached attestation manifests, while simpler exports may omit them.