{"record":{"id":"1c598bcb7aa63772","repo":"hyperledger/fabric","slug":"error-downloading-output-s","errorCode":null,"errorMessage":"Error downloading output: %s","messagePattern":"Error downloading output: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/util/utils.go","lineNumber":168,"sourceCode":"\t\treturn fmt.Errorf(\"Error waiting for container to complete: %s\", err)\n\t}\n\n\t// Wait for stream copying to complete before accessing stdout.\n\tdefer cw.Close()\n\tbuff, _ := io.ReadAll(cw.Reader)\n\tif res.StatusCode > 0 {\n\t\tlogger.Errorf(\"Docker build failed using options: %s\", opts)\n\t\treturn fmt.Errorf(\"Error returned from build: %d \\\"%s\\\"\", res.StatusCode, string(buff))\n\t}\n\n\tlogger.Debugf(\"Build output is %s\", string(buff))\n\n\t// -----------------------------------------------------------------------------------\n\t// Finally, download the result\n\t// -----------------------------------------------------------------------------------\n\tresCont, err := client.CopyFromContainer(context.Background(), container.ID, dcli.CopyFromContainerOptions{SourcePath: \"/chaincode/output/.\"})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error downloading output: %s\", err)\n\t}\n\tdefer resCont.Content.Close()\n\tio.Copy(opts.OutputStream, resCont.Content)\n\n\treturn nil\n}\n\n// ParamsImage returns the go, os version and architecture of the ccenv image\nfunc ParamsImage(client dcli.APIClient) (string, string, string, error) {\n\timage := GetDockerImageFromConfig(\"chaincode.builder\")\n\tif image == \"\" {\n\t\treturn \"\", \"\", \"\", fmt.Errorf(\"No image provided and \\\"chaincode.builder\\\" default does not exist\")\n\t}\n\n\t// -----------------------------------------------------------------------------------\n\t// Ensure the image exists locally, or pull it from a registry if it doesn't\n\t// -----------------------------------------------------------------------------------\n\t_, err := client.ImageInspect(context.Background(), image)","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/util/utils.go#L150-L186","documentation":"After a successful build, DockerBuild copies the artifact tarball from /chaincode/output/. inside the container via CopyFromContainer. If that docker API call fails, this error wraps the docker client error. It means the build itself succeeded but the results could not be retrieved, and note that io.Copy into opts.OutputStream afterwards ignores errors, so this error only covers the copy-from call itself.","triggerScenarios":"client.CopyFromContainer for path /chaincode/output/. returns an error: the builder image/container lacks a /chaincode/output directory (custom image without the expected layout), the container already exited and was removed, or the docker daemon rejects the archive request.","commonSituations":"Using a custom 'chaincode.builder' image that does not create /chaincode/output (the standard ccenv does); another component removing the ephemeral container before the copy (racing with the deferred ContainerRemove); daemon errors mid-build; failed external build (chaincode.externalBuilders misconfig) paths where the expected layout differs.","solutions":["Ensure the builder image creates and populates /chaincode/output — the standard hyperledger/fabric-ccenv image does; custom builders must replicate this layout","Retry the build; if a concurrent removal races the copy, eliminate external 'docker rm' cleanup of peer-managed containers","Check docker daemon health and disk space (a full /var/lib/docker can break archive operations)","Confirm the chaincode package is valid so the build actually wrote artifacts, then re-run package/install"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm the builder image produces /chaincode/output before relying on it\n// run a smoke build once and inspect the archive layout:\n//   docker run --rm <builder> /bin/sh -c 'mkdir -p /chaincode/output'\nif err := util.DockerBuild(probeOpts, client); err != nil {\n    return fmt.Errorf(\"builder smoke test failed: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := util.DockerBuild(opts, client); err != nil {\n    if strings.Contains(err.Error(), \"Error downloading output\") && attempt < maxAttempts {\n        // transient daemon failure: retry the whole build\n        return retryBuild(opts, client, attempt+1)\n    }\n    return err\n}","preventionTips":["Use the standard ccenv builder or ensure custom builders create /chaincode/output","Avoid external cleanup jobs that remove containers while builds run","Keep adequate disk space on the docker daemon host","Retry transient daemon errors rather than failing the chaincode install permanently"],"tags":["docker","copy-from-container","artifact-download","chaincode-build"],"backgroundTag":"docker-artifact-copy-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"}