docker/cli ยท error
must specify at least one container source
Error message
must specify at least one container source
What it means
The default branch of the direction switch in runCopy: neither the source nor the destination argument was recognized as a CONTAINER:PATH reference, so there is no container endpoint at all. docker cp only copies between a container and the local filesystem, so at least one side must name a container.
Source
Thrown at cli/command/container/cp.go:245
var direction copyDirection
if srcContainer != "" {
direction |= fromContainer
copyConfig.container = srcContainer
}
if destContainer != "" {
direction |= toContainer
copyConfig.container = destContainer
}
switch direction {
case fromContainer:
return copyFromContainer(ctx, dockerCli, copyConfig)
case toContainer:
return copyToContainer(ctx, dockerCli, copyConfig)
case acrossContainers:
return errors.New("copying between containers is not supported")
default:
return errors.New("must specify at least one container source")
}
}
func resolveLocalPath(localPath string) (absPath string, _ error) {
absPath, err := filepath.Abs(localPath)
if err != nil {
return "", err
}
return archive.PreserveTrailingDotOrSeparator(absPath, localPath), nil
}
func copyFromContainer(ctx context.Context, dockerCLI command.Cli, copyConfig cpConfig) (err error) {
dstPath := copyConfig.destPath
srcPath := copyConfig.sourcePath
if dstPath != "-" {
// Get an absolute destination path.
dstPath, err = resolveLocalPath(dstPath)View on GitHub (pinned to e9452d6e78)
Solutions
- Prefix the container-side argument with the container name or ID, e.g. `docker cp mycontainer:/var/log/app.log ./`.
- Verify shell variables holding the container name are non-empty before invoking the command.
- Use plain `cp` if both paths are genuinely on the host.
Example fix
# before docker cp /var/log/app.log ./app.log # after docker cp mycontainer:/var/log/app.log ./app.log
When it happens
Trigger: `docker cp ./a ./b` where both arguments are plain local paths (no `container:` prefix on either side), leaving both fromContainer and toContainer direction bits unset.
Common situations: Forgetting the `container:` prefix on the container-side path; scripts where the container name variable is empty so the argument degrades to a bare path (e.g. `docker cp "$CTR:/logs" .` with $CTR unset yields `:/logs` edge cases); confusing docker cp with plain cp.
Related errors
- destination can not be empty
- copying between containers is not supported
- content size not available for stdin
- you cannot start and attach multiple containers at once
- got a device
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/1d70827a5ac5492b.json.
Report an issue: GitHub.