Sub topic 10
Choosing provenance mode min or max
This chapter assumes you can already build and push an image with docker buildx build, and that you know how to read JSON with jq. Earlier chapters covered how provenance is attached to an image index. Here you decide how much detail the provenance attestation should record.
What the mode controls
BuildKit generates provenance in one of two modes. The mode changes how much of the build is written into the SLSA provenance predicate. It does not change whether the attestation exists, where it is stored, or how you read it.
minrecords the facts a consumer needs to identify the build and its inputs.maxrecords everything inminplus the details needed to reproduce and debug the build.
Provenance is also enabled by default for builds that push an image, with mode=min. You only need to set the mode when you want max, or when you want to turn provenance off.
What each mode contains
The table summarizes the differences. Field names refer to the SLSA v0.2 predicate that Buildx emits.
| Information | `min` | `max` |
|---|---|---|
| Builder ID, build type, start and finish times | Yes | Yes |
| Materials (base images and other sources, with digests) | Yes | Yes |
| Source repository and frontend used | Yes | Yes |
| Values of `--build-arg` arguments | No | Yes |
| Full Dockerfile content | No | Yes |
| BuildKit-specific metadata: layer details, source maps, VCS information | No | Yes |
| The LLB build definition (the internal build graph) | No | Yes |
Two details matter in practice:
maxstores the Dockerfile text inside the attestation. Anyone who can pull the image can read it.maxstores build argument values. If a team passes a token with--build-arg,maxpublishes that token next to the image.
Values passed with --secret are not recorded in either mode. That is the main reason to use secret mounts instead of build arguments for sensitive data.
Selecting a mode
The short form and the long form are equivalent. Each sets the mode.
docker buildx build \
--sbom=true \
--provenance=mode=max \
--tag registry.example.com/demo/app:1.0 \
--push .docker buildx build \
--attest type=sbom \
--attest type=provenance,mode=min \
--tag registry.example.com/demo/app:1.0 \
--push .--provenance=true means mode=min. --provenance=false turns provenance off, which helps when a consumer or registry cannot handle the extra manifests.
docker buildx build \
--provenance=false \
--tag demo/app:no-provenance \
--push .The provenance option accepts more attributes after the mode, separated by commas. Two useful ones are builder-id=<url>, which sets an identifier for the builder that appears in the attestation, and filename=<name>, which records which Dockerfile was used. Check docker buildx build --help for the list your Buildx version supports.
Seeing the difference
The easiest way to understand the modes is to build the same image twice and compare. Use this Dockerfile, which takes a build argument:
FROM alpine:3.20
ARG BUILD_ENV=dev
RUN apk add --no-cache curl && echo "env=$BUILD_ENV" > /etc/build-env
CMD ["cat", "/etc/build-env"]Build and push it once per mode, with a single platform so the output has one provenance document:
docker buildx build \
--platform linux/amd64 \
--build-arg BUILD_ENV=staging \
--provenance=mode=min \
--tag registry.example.com/demo/app:min \
--push .
docker buildx build \
--platform linux/amd64 \
--build-arg BUILD_ENV=staging \
--provenance=mode=max \
--tag registry.example.com/demo/app:max \
--push .Now read the build arguments from each attestation:
for tag in min max; do
echo "== $tag =="
docker buildx imagetools inspect registry.example.com/demo/app:$tag \
--format '{{ json .Provenance }}' \
| jq '.SLSA.invocation.parameters.args // {}'
doneFor min, you should see an empty object or only frontend settings. For max, you should also see an entry such as "build-arg:BUILD_ENV": "staging". If you build for several platforms, the JSON is keyed by platform first, so use .["linux/amd64"].SLSA as the path prefix.
To see which extra sections max adds, list the keys of the metadata object for each tag:
for tag in min max; do
echo "== $tag =="
docker buildx imagetools inspect registry.example.com/demo/app:$tag \
--format '{{ json .Provenance }}' \
| jq '.SLSA.metadata | keys'
doneThe max output includes a BuildKit-specific key under https://mobyproject.org/buildkit@v1. That key holds the Dockerfile source, layer information and VCS data.
Choosing between them
The choice is a trade-off between auditability and exposure.
Use min when:
- The image is public, and your Dockerfile or build arguments are not meant to be public.
- Consumers only need to know the builder, the base images and the source revision.
- You want the smallest attestation, for example to keep registry storage low.
Use max when:
- The image is internal, and the people who can pull it are the same people who may read your Dockerfile.
- Auditors or incident responders need to see the exact build inputs and the Dockerfile that produced a given digest.
- You plan to feed the attestation into a policy engine that checks build arguments or Dockerfile content.
A common compromise is max for internal registries and min for images that go to a public registry. Because the mode is a build option, a CI pipeline can choose it per target.
Edge cases and mistakes
- Secrets in build arguments. Build arguments already appear in
docker historyoutput for the image, so they were never safe.maxadds a second, structured copy. Rotate any token that has been through amaxbuild, then move it to--secret. - Private repository URLs. The source field can contain a Git URL. If the URL embeds credentials, both modes record it. Use an SSH remote or a credential helper instead.
- Comparing digests across modes. Provenance is stored as a separate manifest, so the image digest of a platform manifest does not change with the mode. The index digest does change, because it lists a different attestation manifest. If you pin by index digest, a rebuild in another mode gives a new pin.
- Builds that only load locally. The default
dockerdriver with the classic image store does not store attestations. You need a builder and an output that support them, as covered in the drivers chapter. - Assuming
maxmeans verified. A larger attestation does not make the contents more trustworthy. Without a signature, anyone with registry write access can replace it.
Summary of the decision
min is the safe default and gives consumers the builder, materials and source. max adds Dockerfile content, build argument values and BuildKit metadata, which help audits but expose more. Pick the mode per image based on who can read the registry and what your build inputs contain.
Exercise
A team builds a public image with --build-arg NPM_TOKEN=abc123 and --provenance=mode=max. What is exposed, and what two changes fix it?
Show answer
In max mode the attestation records build argument values, so the token abc123 is readable by anyone who can pull the image (and it already shows in docker history). Fix it by passing the token with --secret and a secret mount in the Dockerfile instead of a build argument, and by rotating the exposed token. Using --provenance=mode=min for the public image would also stop the Dockerfile and argument values from being recorded.
Exercise
You build one image with --provenance=mode=min and again with --provenance=mode=max. Which jq path would you use on the output of docker buildx imagetools inspect --format '{{ json .Provenance }}' to compare build arguments for a single-platform image, and what difference do you expect?
Show answer
Use .SLSA.invocation.parameters.args. The min output has no build-arg: entries, while the max output lists each build argument, for example "build-arg:BUILD_ENV": "staging". For a multi-platform image, prefix the path with the platform key, such as .["linux/amd64"].