docker/cli · error
copying between containers is not supported
Error message
copying between containers is not supported
What it means
In runCopy, the CLI parses both arguments for a CONTAINER:PATH form and sets direction bits fromContainer/toContainer. When both source and destination name a container (direction == acrossContainers), it returns this error because the Docker API has no endpoint to copy directly between two containers — the CLI only supports container↔local-filesystem transfers.
Source
Thrown at cli/command/container/cp.go:243
}
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 != "-" {View on GitHub (pinned to e9452d6e78)
Solutions
- Copy in two steps through the host: `docker cp containerA:/path ./tmp && docker cp ./tmp containerB:/path`.
- Stream via tar to avoid a temp dir: `docker exec containerA tar -C /path -cf - . | docker exec -i containerB tar -C /path -xf -`.
- Share data via a named volume mounted into both containers instead of copying.
Example fix
# before docker cp appA:/data appB:/data # after docker cp appA:/data ./data docker cp ./data appB:/data
When it happens
Trigger: `docker cp containerA:/path containerB:/path` — both positional args contain a colon-prefixed container reference, setting both direction flags.
Common situations: Users assuming docker cp works like scp between two remote endpoints; migration scripts trying to move data between containers directly; paths on the local filesystem that contain a colon being misparsed as container references.
Related errors
- destination can not be empty
- must specify at least one container source
- content size not available for stdin
- got a device
- got an irregular file
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/b243466156935b68.json.
Report an issue: GitHub.