{"id":"b243466156935b68","repo":"docker/cli","slug":"copying-between-containers-is-not-supported","errorCode":null,"errorMessage":"copying between containers is not supported","messagePattern":"copying between containers is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/cp.go","lineNumber":243,"sourceCode":"\t}\n\n\tvar direction copyDirection\n\tif srcContainer != \"\" {\n\t\tdirection |= fromContainer\n\t\tcopyConfig.container = srcContainer\n\t}\n\tif destContainer != \"\" {\n\t\tdirection |= toContainer\n\t\tcopyConfig.container = destContainer\n\t}\n\n\tswitch direction {\n\tcase fromContainer:\n\t\treturn copyFromContainer(ctx, dockerCli, copyConfig)\n\tcase toContainer:\n\t\treturn copyToContainer(ctx, dockerCli, copyConfig)\n\tcase acrossContainers:\n\t\treturn errors.New(\"copying between containers is not supported\")\n\tdefault:\n\t\treturn errors.New(\"must specify at least one container source\")\n\t}\n}\n\nfunc resolveLocalPath(localPath string) (absPath string, _ error) {\n\tabsPath, err := filepath.Abs(localPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn archive.PreserveTrailingDotOrSeparator(absPath, localPath), nil\n}\n\nfunc copyFromContainer(ctx context.Context, dockerCLI command.Cli, copyConfig cpConfig) (err error) {\n\tdstPath := copyConfig.destPath\n\tsrcPath := copyConfig.sourcePath\n\n\tif dstPath != \"-\" {","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/cp.go#L225-L261","documentation":"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.","triggerScenarios":"`docker cp containerA:/path containerB:/path` — both positional args contain a colon-prefixed container reference, setting both direction flags.","commonSituations":"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.","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."],"exampleFix":"# before\ndocker cp appA:/data appB:/data\n# after\ndocker cp appA:/data ./data\ndocker cp ./data appB:/data","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","docker-cp","unsupported-operation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}