hyperledger/fabric · error
Error executing build: %s "%s"
Error message
Error executing build: %s "%s"
What it means
DockerBuild starts an ephemeral builder container whose Cmd compiles chaincode inside the builder image. When docker's ContainerStart API itself fails (container cannot be started, e.g. bad entrypoint/cmd or image problem), the function reads whatever the container emitted on its attached stdout/stderr and wraps both the docker error and that buffer into this error. It indicates the build process never got to run, as opposed to a build that ran and returned a non-zero exit code.
Source
Thrown at core/chaincode/platforms/util/utils.go:138
// -----------------------------------------------------------------------------------
cw, err := client.ContainerAttach(context.Background(), container.ID, dcli.ContainerAttachOptions{
Stream: true,
Stdout: true,
Stderr: true,
Logs: true,
})
if err != nil {
return fmt.Errorf("Error attaching to container: %s", err)
}
// -----------------------------------------------------------------------------------
// Launch the actual build, realizing the Env/Cmd specified at container creation
// -----------------------------------------------------------------------------------
_, err = client.ContainerStart(context.Background(), container.ID, dcli.ContainerStartOptions{})
if err != nil {
buff, _ := io.ReadAll(cw.Reader)
cw.Close()
return fmt.Errorf("Error executing build: %s \"%s\"", err, string(buff))
}
// -----------------------------------------------------------------------------------
// Wait for the build to complete and gather the return value
// -----------------------------------------------------------------------------------
resWait := client.ContainerWait(context.Background(), container.ID, dcli.ContainerWaitOptions{})
var res dcontainer.WaitResponse
select {
case res = <-resWait.Result:
case err = <-resWait.Error:
cw.Close()
return fmt.Errorf("Error waiting for container to complete: %s", err)
}
// Wait for stream copying to complete before accessing stdout.
defer cw.Close()
buff, _ := io.ReadAll(cw.Reader)
if res.StatusCode > 0 {View on GitHub (pinned to 2736b63f8f)
Solutions
- Inspect the quoted output buffer in the message: it contains the container's stdout/stderr, usually showing 'exec: /bin/sh: not found' or an OCI runtime error
- Use a builder image that includes /bin/sh (e.g. a standard golang/node ccenv image) since the Cmd is always wrapped as ['/bin/sh','-c',opts.Cmd]
- Verify the image matches the daemon architecture (docker image inspect <image>) and that it is present locally or pullable
- Check docker daemon health (docker info / journalctl -u docker) for runtime or resource errors and restart it if needed
Example fix
// before: minimal image without a shell
opts := DockerBuildOptions{Image: "scratch-based-builder", Cmd: "go build"}
// after: use an image with /bin/sh so the '/bin/sh -c' wrapper can run
opts := DockerBuildOptions{Image: "hyperledger/fabric-ccenv:latest", Cmd: "go build"} Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the builder image exists and contains /bin/sh before building
img, err := client.ImageInspect(ctx, opts.Image)
if err != nil { return fmt.Errorf("builder image %s missing: %w", opts.Image, err) }
// optionally: docker run --rm --entrypoint /bin/sh <img> -c 'echo ok' Try / catch
if err := util.DockerBuild(opts, client); err != nil {
if strings.Contains(err.Error(), "Error executing build") {
// parse quoted output; check for exec/sh errors and image/runtime problems
logger.Errorf("builder container failed to start: %v", err)
}
return err
} Prevention
- Always use a builder image that includes /bin/sh (the Cmd is wrapped as /bin/sh -c)
- Keep opts.Image aligned with your host architecture and Fabric version
- Pre-pull the image before install/instantiate so start-time surprises are reduced
- Monitor docker daemon health where chaincode builds run
When it happens
Trigger: client.ContainerStart returns an error: the builder image lacks /bin/sh or the entrypoint cannot exec, the image was removed between pull and start, the docker daemon rejects the start (e.g. runtime/OCI error), or the container ID is invalid after a failed create path.
Common situations: Using a minimal/slim builder image that has no shell (/bin/sh) so the wrapping command `['/bin/sh','-c',cmd]` cannot exec; broken or incompatible builder image for the host architecture (e.g. arm64 image on amd64 daemon); Docker daemon restarted or out of resources mid-build; misconfigured 'chaincode.builder' core.yaml property pointing at a non-runnable image.
Related errors
- Error returned from build: %d "%s"
- platform builder failed
- Error waiting for container to complete: %s
- Error downloading output: %s
- docker image build failed
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/5e7c608c0bd10085.
Report an issue: GitHub.