docker/compose · error

build result not found in Bake metadata for service %s

Error message

build result not found in Bake metadata for service %s

What it means

After a successful bake, compose reads the JSON metadata file written by buildx to map each built target to its image digest. If the metadata map has no entry for the target corresponding to a requested service, the build result cannot be attributed and this error is returned naming the service. It indicates the bake run did not actually produce (or record) a result for that target — typically target-name mismatches or buildx output configuration (e.g. no exporter) that skips metadata entries.

Source

Thrown at pkg/compose/build_bake.go:418

	var md bakeMetadata
	err = json.Unmarshal(b, &md)
	if err != nil {
		return nil, err
	}

	// Bake reports the top-level attested image/index digest, which changes on
	// every build when provenance attestations are enabled — even for a fully
	// cached build (see https://github.com/docker/compose/issues/13636). For
	// images loaded into the local engine (the common non-push case), resolve
	// the canonical content digest — with the service's pinned platform when
	// set — so unchanged rebuilds don't recreate containers.
	results := map[string]string{}
	for name, service := range serviceToBeBuild {
		image := expectedImages[name]
		target := targets[name]
		built, ok := md[target]
		if !ok {
			return nil, fmt.Errorf("build result not found in Bake metadata for service %s", name)
		}
		results[image] = s.canonicalBuiltDigest(ctx, image, service.Platform, built.Digest)
		s.events.On(builtEvent(image))
	}

	return results, nil
}

func (s *composeService) getBuildxPlugin() (*manager.Plugin, error) {
	buildx, err := manager.GetPlugin("buildx", s.dockerCli, &cobra.Command{})
	if err != nil {
		return nil, err
	}

	if buildx.Err != nil {
		return nil, buildx.Err
	}

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Upgrade docker compose and buildx together to versions known compatible (buildx >= 0.17.0 for this compose)
  2. Remove custom bake overrides (COMPOSE_BAKE env, docker-bake.hcl) that rename or drop the service's target
  3. Inspect the metadata file left by buildx (set --metadata-file in a direct docker buildx bake run) to see which target names are recorded and align names
  4. Fall back to the classic builder (COMPOSE_BAKE=false) to unblock while diagnosing

Example fix

# before
$ COMPOSE_BAKE=true docker compose build web   # build result not found in Bake metadata for service web
# after — remove conflicting override and retry
$ unset OVERRIDE_BAKE_FLAGS
$ docker compose build web
# or bypass bake while diagnosing
$ COMPOSE_BAKE=false docker compose build web
Defensive patterns

Strategy: fallback

Try / catch

if err := composeBuild(); err != nil {
	if strings.Contains(err.Error(), "build result not found in Bake metadata") {
		// metadata/target mismatch: fall back to classic build, then align versions
		os.Setenv("COMPOSE_BAKE", "false")
		return composeBuild()
	}
	return err
}

Prevention

When it happens

Trigger: Building with bake where the service's build target resolves to a name absent from the metadata file; custom bakes or COMPOSE_BAKE overrides that rename or merge targets; buildx versions writing a different metadata schema; targets configured with cache-only or no output so no result is recorded.

Common situations: Using a custom docker-bake.hcl or bake overrides alongside compose; downgrading/patching buildx so metadata keys change; services whose build produces no loadable image; compose/buildx version skew.

Related errors


AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15). Data as JSON: /api/errors/793c127166ac9f6e. Report an issue: GitHub.