{"record":{"id":"70ce6d8f6f64b10f","repo":"hyperledger/fabric","slug":"error-uploading-input-to-container-s","errorCode":null,"errorMessage":"Error uploading input to container: %s","messagePattern":"Error uploading input to container: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/util/utils.go","lineNumber":115,"sourceCode":"\t\t\tCmd:          []string{\"/bin/sh\", \"-c\", opts.Cmd},\n\t\t\tImage:        opts.Image,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error creating container: %s\", err)\n\t}\n\tdefer client.ContainerRemove(context.Background(), container.ID, dcli.ContainerRemoveOptions{})\n\n\t// -----------------------------------------------------------------------------------\n\t// Upload our input stream\n\t// -----------------------------------------------------------------------------------\n\t_, err = client.CopyToContainer(context.Background(), container.ID, dcli.CopyToContainerOptions{\n\t\tDestinationPath:           \"/chaincode/input\",\n\t\tContent:                   opts.InputStream,\n\t\tAllowOverwriteDirWithFile: true,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error uploading input to container: %s\", err)\n\t}\n\n\t// -----------------------------------------------------------------------------------\n\t// Attach stdout buffer to capture possible compilation errors\n\t// -----------------------------------------------------------------------------------\n\tcw, err := client.ContainerAttach(context.Background(), container.ID, dcli.ContainerAttachOptions{\n\t\tStream: true,\n\t\tStdout: true,\n\t\tStderr: true,\n\t\tLogs:   true,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error attaching to container: %s\", err)\n\t}\n\n\t// -----------------------------------------------------------------------------------\n\t// Launch the actual build, realizing the Env/Cmd specified at container creation\n\t// -----------------------------------------------------------------------------------","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/util/utils.go#L97-L133","documentation":"DockerBuild copies the chaincode code package tar into the ephemeral container at /chaincode/input via client.CopyToContainer. This error means the upload failed, so the builder cannot see the sources to compile. The docker API error is embedded via %s.","triggerScenarios":"CopyToContainer errors: container not running/stopped, /chaincode/input path issues, broken or unreadable InputStream (code package tar), or daemon I/O failure.","commonSituations":"Corrupt chaincode package streams, destination path conflicts on the builder image, or the container exiting immediately after creation due to a bad image entrypoint.","solutions":["Inspect the embedded docker error for the copy failure cause","Verify the code package InputStream is a valid, readable tar","Ensure the builder image contains /chaincode/input and stays alive during the copy","Re-create the container and retry the build"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if opts.InputStream == nil {\n    return fmt.Errorf(\"InputStream (code package tar) must be provided\")\n}\nif _, err := opts.InputStream.Seek(0, io.SeekEnd); err != nil {\n    return fmt.Errorf(\"input stream unreadable: %w\", err)\n}\nopts.InputStream.Seek(0, io.SeekStart)","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"Error uploading input\") {\n    logger.Errorf(\"CopyToContainer failed: %s — verify tar validity and container liveness\", err)\n    return err\n}","preventionTips":["Verify chaincode packages are valid tars before building","Ensure the builder image keeps /chaincode/input and stays alive","Check daemon logs for I/O errors on the docker host"],"tags":["docker","container","io","chaincode-package"],"backgroundTag":"container-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"}