docker/cli · info
content size not available for stdin
Error message
content size not available for stdin
What it means
In copyToContainer, when the source is `-` the CLI reads a tar archive from stdin and sets sizeErr to this error instead of a byte count, because a stream's total size cannot be known up front. It is a sentinel used to disable the copy progress display, not a fatal failure of the copy itself — though it surfaces where code paths need the content size.
Source
Thrown at cli/command/container/cp.go:412
// type of conflict (e.g., non-directory overwriting an existing directory
// or vice versa) the extraction will fail. If the destination simply did
// not exist, but the parent directory does, the extraction will still
// succeed.
_ = err // Intentionally ignore stat errors (see above)
}
var (
content io.ReadCloser
resolvedDstPath string
copiedSize int64
contentSize int64
sizeErr error
)
if srcPath == "-" {
content = os.Stdin
resolvedDstPath = dstInfo.Path
sizeErr = errors.New("content size not available for stdin")
if !dstInfo.IsDir {
return fmt.Errorf(`destination "%s:%s" must be a directory`, copyConfig.container, dstPath)
}
} else {
// Prepare source copy info.
srcInfo, err := archive.CopyInfoSourcePath(srcPath, copyConfig.followLink)
if err != nil {
return err
}
contentSize, sizeErr = localContentSize(srcInfo.Path)
srcArchive, err := archive.TarResource(srcInfo)
if err != nil {
return err
}
defer srcArchive.Close()
View on GitHub (pinned to e9452d6e78)
Solutions
- No fix needed for the copy itself — it proceeds; the size is simply unavailable for stdin, so progress reporting is skipped.
- If you need size reporting, write the tar to a file first and copy the file/directory by path instead of streaming via `-`.
- Ensure the stdin source is a valid tar archive and the destination is an existing directory (a non-directory destination fails separately).
When it happens
Trigger: `docker cp - mycontainer:/dest/dir` (tar archive piped on stdin). localContentSize is never called; sizeErr is pre-set at cp.go:412 since os.Stdin has no determinable length.
Common situations: Piping tar streams into containers (`tar -cf - . | docker cp - ctr:/app`) and wondering why no progress/size is shown; tooling that parses cp output expecting a size.
Related errors
- error reading from STDIN: data is empty
- destination can not be empty
- copying between containers is not supported
- must specify at least one container source
- invalid argument: can't use stdin for both build context and
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/08bb95da4b54036a.json.
Report an issue: GitHub.