docker/compose · error
failed to execute bake: %w
Error message
failed to execute bake: %w
What it means
While streaming buildx bake's progress from its stdout, compose reads line by line; any read error other than io.EOF (normal end) and os.ErrClosed (bake stopped early on purpose) aborts with this error wrapping the read failure. In practice the pipe broke — typically the buildx process died (killed, OOM, plugin crash) or wrote garbage that closed the stream unexpectedly.
Source
Thrown at pkg/compose/build_bake.go:370
var errMessage []string
reader := bufio.NewReader(pipe)
err = cmd.Start()
if err != nil {
return nil, err
}
eg.Go(cmd.Wait)
for {
line, readErr := reader.ReadString('\n')
if readErr != nil {
if readErr == io.EOF {
break
}
if errors.Is(readErr, os.ErrClosed) {
logrus.Debugf("bake stopped")
break
}
return nil, fmt.Errorf("failed to execute bake: %w", readErr)
}
decoder := json.NewDecoder(strings.NewReader(line))
var status client.SolveStatus
err := decoder.Decode(&status)
if err != nil {
if strings.HasPrefix(line, "ERROR: ") {
errMessage = append(errMessage, line[7:])
} else {
errMessage = append(errMessage, line)
}
continue
}
ch <- &status
}
close(ch) // stop build progress UI
err = eg.Wait()
if err != nil {View on GitHub (pinned to ddc4b044b6)
Solutions
- Re-run the build — transient process deaths (OOM, daemon restart) usually do not recur
- Check dmesg/journal for OOM kills of buildx and free memory or raise limits before retrying
- Upgrade the buildx plugin to a stable release (docker buildx version; reinstall via dockerCLI plugin management)
- If it reproduces deterministically, capture the failing service/target and run docker buildx bake <target> directly to get buildx's own error
Defensive patterns
Strategy: retry
Try / catch
if err := composeBuild(); err != nil {
if strings.Contains(err.Error(), "failed to execute bake") && isTransient(errors.Unwrap(err)) {
// transient pipe/process failure: back off and retry once
time.Sleep(2 * time.Second)
return composeBuild()
}
return err
} Prevention
- Provision enough memory for buildx in CI (OOM kills are the top cause of dropped bake pipes)
- Keep buildx/BuildKit versions current to avoid plugin crashes
- Do not restart dockerd or prune the builder during active builds
When it happens
Trigger: docker compose build (bake path) where the buildx plugin process is killed mid-build (OOM killer, manual kill, container runtime stop); buildx crashing on a malformed definition; the stdout pipe being closed from the child side without EOF.
Common situations: Memory-constrained CI machines OOM-killing buildx during large builds; upgrading/downgrading the buildx plugin while a build runs; buildx bugs crashing on specific bake targets; dockerd restarts mid-build.
Related errors
- build result not found in Bake metadata for service %s
- reading blob %s: %w
- invalid PID (%d): only positive PIDs are allowed
- process with PID %d is still running
- copying %q: %w
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/22dbb6803cfa0b7a.
Report an issue: GitHub.