build: Fix iidfile for containerd-backed Docker driver

Images loaded into Docker's containerd image store are identified by
their manifest or index digest, while the legacy graphdriver store uses
the config digest.

buildx prefers containerimage.config.digest when the Moby exporter
returns both digests.
Some exporter responses still produce a usable iidfile, but affected
builds, such as those with attestations disabled, write a config digest
that Docker image commands cannot resolve.

Expose the Docker driver's image-store mode as a feature and set
prefer-image-digest for containerd-backed Moby exports.

Signed-off-by: Paweł Gronowski <git@grono.dev>
This commit is contained in:
Paweł Gronowski
2026-07-13 20:01:34 +02:00
parent aadce022ac
commit 21de7d2078
5 changed files with 22 additions and 9 deletions
+4
View File
@@ -491,6 +491,10 @@ func toSolveOpt(ctx context.Context, np *noderesolver.ResolvedNode, multiDriver
}
if e.Type == "image" && nodeDriver.IsMobyDriver() {
opt.Exports[i].Type = "moby"
// The containerd image store resolves images by manifest or index digest.
if nodeDriver.Features(ctx)[driver.PreferImageDigest] {
opt.Exports[i].Attrs["prefer-image-digest"] = "true"
}
if e.Attrs["push"] != "" {
if ok, _ := strconv.ParseBool(e.Attrs["push"]); ok {
if ok, _ := strconv.ParseBool(e.Attrs["push-by-digest"]); ok {