{"record":{"id":"9d433151dd0490c0","repo":"docker/compose","slug":"destination-s-s-must-be-a-directory-or-a-regul","errorCode":null,"errorMessage":"destination \"%s:%s\" must be a directory or a regular file: %w","messagePattern":"destination \"(.+?):(.+?)\" must be a directory or a regular file: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/cp.go","lineNumber":185,"sourceCode":"\t\tlinkTarget := dstStat.LinkTarget\n\t\tif !isAbs(linkTarget) {\n\t\t\t// Join with the parent directory.\n\t\t\tdstParent, _ := archive.SplitPathDirEntry(dstPath)\n\t\t\tlinkTarget = filepath.Join(dstParent, linkTarget)\n\t\t}\n\n\t\tdstInfo.Path = linkTarget\n\t\tres, err = s.apiClient().ContainerStatPath(ctx, containerID, client.ContainerStatPathOptions{\n\t\t\tPath: linkTarget,\n\t\t})\n\t\tif err == nil {\n\t\t\tdstStat = res.Stat\n\t\t}\n\t}\n\n\t// Validate the destination path\n\tif err := command.ValidateOutputPathFileMode(dstStat.Mode); err != nil {\n\t\treturn fmt.Errorf(`destination \"%s:%s\" must be a directory or a regular file: %w`, containerID, dstPath, err)\n\t}\n\n\t// Ignore any error and assume that the parent directory of the destination\n\t// path exists, in which case the copy may still succeed. If there is any\n\t// type of conflict (e.g., non-directory overwriting an existing directory\n\t// or vice versa) the extraction will fail. If the destination simply did\n\t// not exist, but the parent directory does, the extraction will still\n\t// succeed.\n\tif err == nil {\n\t\tdstInfo.Exists, dstInfo.IsDir = true, dstStat.Mode.IsDir()\n\t}\n\n\tvar (\n\t\tcontent         io.Reader\n\t\tresolvedDstPath string\n\t)\n\n\tif srcPath == \"-\" {","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/cp.go#L167-L203","documentation":"Error \"destination \"%s:%s\" must be a directory or a regular file: %w\" thrown in docker/compose.","triggerScenarios":"During 'docker compose cp' into a container, the destination path inside the container is neither a directory nor a regular file, so the copy target is invalid.","commonSituations":"The destination is a symlink to something unusual, a special device, or a non-existent path when copying multiple sources which require a directory target.","solutions":["Choose a destination path inside the container that is an existing directory or a regular file path.","Create the destination directory in the container first (docker compose exec <service> mkdir -p <path>), then retry the copy."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}