{"record":{"id":"dcdde1a8ddb0bde6","repo":"hyperledger/fabric","slug":"docker-build-failed","errorCode":null,"errorMessage":"docker build failed","messagePattern":"docker build failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/platforms.go","lineNumber":155,"sourceCode":"\tif ccType == pb.ChaincodeSpec_GOLANG.String() {\n\t\tgoVersion, osVersion, archVersion, err = util.ParamsImage(client)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"get params docker image failed\")\n\t\t}\n\t}\n\n\tbuildOptions, err := platform.DockerBuildOptions(path, goVersion, osVersion, archVersion)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"platform failed to create docker build options\")\n\t}\n\n\toutput := &bytes.Buffer{}\n\tbuildOptions.InputStream = codePackage\n\tbuildOptions.OutputStream = output\n\n\terr = r.DockerBuild(buildOptions, client)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"docker build failed\")\n\t}\n\n\treturn writeBytesToPackage(\"binpackage.tar\", output.Bytes(), tw)\n}\n\nfunc writeBytesToPackage(name string, payload []byte, tw *tar.Writer) error {\n\terr := tw.WriteHeader(&tar.Header{\n\t\tName: name,\n\t\tSize: int64(len(payload)),\n\t\tMode: 0o100644,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = tw.Write(payload)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/platforms.go#L137-L173","documentation":"This wrap fires when the actual docker build (r.DockerBuild) executed inside the builder container returns an error. The chaincode source was streamed to the builder image but compilation/packaging failed, so no binary package can be written to the tar. The docker build output (compilation errors) is typically included in the wrapped error.","triggerScenarios":"Calling StreamDockerBuild where the builder container's build command (e.g. go build of the chaincode) exits non-zero, or the docker build itself fails (missing builder image, daemon error).","commonSituations":"Chaincode source that does not compile, vendor/dependency issues, a broken or missing chaincode.builder image, or docker daemon problems during chaincode install.","solutions":["Read the wrapped error output for compiler/build output from the builder container","Fix compilation errors in the chaincode source and repackage","Ensure the chaincode.builder image exists locally or is pullable","Verify the docker daemon is healthy and has disk space"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure builder image exists before building\nif _, err := client.ImageInspect(context.Background(), builderImage); err != nil {\n    return fmt.Errorf(\"builder image %s unavailable: %w\", builderImage, err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    logger.Errorf(\"docker build failed, output: %s\", output.String())\n    return errors.Wrap(err, \"docker build failed\")\n}","preventionTips":["Compile chaincode locally (go build) before packaging to catch errors early","Keep the chaincode.builder image current and pullable","Monitor docker daemon health and disk space on build hosts","Pin dependencies/vendor directories to avoid build flakiness"],"tags":["docker","build","go-chaincode","compilation"],"backgroundTag":"docker-build-failed","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}