hyperledger/fabric · error
Error uploading input to container: %s
Error message
Error uploading input to container: %s
What it means
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.
Source
Thrown at core/chaincode/platforms/util/utils.go:115
Cmd: []string{"/bin/sh", "-c", opts.Cmd},
Image: opts.Image,
},
})
if err != nil {
return fmt.Errorf("Error creating container: %s", err)
}
defer client.ContainerRemove(context.Background(), container.ID, dcli.ContainerRemoveOptions{})
// -----------------------------------------------------------------------------------
// Upload our input stream
// -----------------------------------------------------------------------------------
_, err = client.CopyToContainer(context.Background(), container.ID, dcli.CopyToContainerOptions{
DestinationPath: "/chaincode/input",
Content: opts.InputStream,
AllowOverwriteDirWithFile: true,
})
if err != nil {
return fmt.Errorf("Error uploading input to container: %s", err)
}
// -----------------------------------------------------------------------------------
// Attach stdout buffer to capture possible compilation errors
// -----------------------------------------------------------------------------------
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
// -----------------------------------------------------------------------------------View on GitHub (pinned to 2736b63f8f)
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
Defensive patterns
Strategy: validation
Validate before calling
if opts.InputStream == nil {
return fmt.Errorf("InputStream (code package tar) must be provided")
}
if _, err := opts.InputStream.Seek(0, io.SeekEnd); err != nil {
return fmt.Errorf("input stream unreadable: %w", err)
}
opts.InputStream.Seek(0, io.SeekStart) Try / catch
if err != nil && strings.Contains(err.Error(), "Error uploading input") {
logger.Errorf("CopyToContainer failed: %s — verify tar validity and container liveness", err)
return err
} Prevention
- 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
When it happens
Trigger: CopyToContainer errors: container not running/stopped, /chaincode/input path issues, broken or unreadable InputStream (code package tar), or daemon I/O failure.
Common situations: Corrupt chaincode package streams, destination path conflicts on the builder image, or the container exiting immediately after creation due to a bad image entrypoint.
Related errors
- Failed to inject "%s": %s
- Error creating container: %s
- Error attaching to container: %s
- failed to wait on container exit
- Error uploading files to the container instance %s: %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/70ce6d8f6f64b10f.
Report an issue: GitHub.