Skip to content

build: print the image ID with --quiet when using the containerd worker - #5170

Open
locker95 wants to merge 1 commit into
containerd:mainfrom
locker95:build-quiet-print-id
Open

build: print the image ID with --quiet when using the containerd worker#5170
locker95 wants to merge 1 commit into
containerd:mainfrom
locker95:build-quiet-print-id

Conversation

@locker95

@locker95 locker95 commented Sep 1, 2026

Copy link
Copy Markdown

Fixes #2015.

As confirmed by @suyanhanx, and per the root cause identified by @austinvazquez ("Image digest is printed during quiet mode only if image is loaded"): with the containerd worker, needsLoading is false and build -q printed nothing, so nerdctl run $(nerdctl build -q .) could not work. This change also requests a buildkit --metadata-file in quiet mode when the image is not loaded, and prints containerimage.digest to stdout after a successful build — the same format the load path prints.

The metadata temp file is consumed (and removed) whenever created; a missing digest stays fatal for --iidfile but is only a debug log in quiet mode, since some outputs (e.g. --output type=local) legitimately carry no image digest.

Testing: a unit test covers digest extraction and temp-file removal (verified locally on macOS); a new TestBuildQuiet integration test asserts the stdout of build -q is a valid digest and that the printed ID is runnable. Locally I could only compile-verify the Linux/buildkitd path (GOOS=linux go build ./... / go vet / go test -c), so I am relying on CI for end-to-end verification.

This patch was developed with the assistance of an AI tool (Claude); I have reviewed and tested the change and take responsibility for it.

When buildkitd runs with the containerd worker, the built image does
not need loading into the image store, and `nerdctl build -q` printed
nothing: the digest was only printed by the load path taken with the
OCI worker. Request a buildkit metadata file in quiet mode too, and
print the digest from it after a successful build, so that `build -q`
consistently outputs the image identifier.

Fixes containerd#2015

Signed-off-by: Dean Chen <862469039@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nerdctl build -q not output imageid after build done

1 participant