{"id":"85121bc2a4d8ab30","repo":"docker/cli","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":"cli/command/container/cp.go","lineNumber":387,"sourceCode":"\t// Prepare destination copy info by stat-ing the container path.\n\tdstInfo := archive.CopyInfo{Path: dstPath}\n\tif dst, err := apiClient.ContainerStatPath(ctx, copyConfig.container, client.ContainerStatPathOptions{Path: dstPath}); err == nil {\n\t\t// If the destination is a symbolic link, we should evaluate it.\n\t\tif dst.Stat.Mode&os.ModeSymlink != 0 {\n\t\t\tlinkTarget := dst.Stat.LinkTarget\n\t\t\tif !isAbs(linkTarget) {\n\t\t\t\t// Join with the parent directory.\n\t\t\t\tdstParent, _ := archive.SplitPathDirEntry(dstPath)\n\t\t\t\tlinkTarget = filepath.Join(dstParent, linkTarget)\n\t\t\t}\n\n\t\t\tdstInfo.Path = linkTarget\n\t\t\tdst, err = apiClient.ContainerStatPath(ctx, copyConfig.container, client.ContainerStatPathOptions{Path: linkTarget})\n\t\t}\n\t\t// Validate the destination path\n\t\tif err == nil {\n\t\t\tif err := command.ValidateOutputPathFileMode(dst.Stat.Mode); err != nil {\n\t\t\t\treturn fmt.Errorf(`destination \"%s:%s\" must be a directory or a regular file: %w`, copyConfig.container, dstPath, err)\n\t\t\t}\n\t\t\tdstInfo.Exists, dstInfo.IsDir = true, dst.Stat.Mode.IsDir()\n\t\t}\n\n\t\t// Ignore any error and assume that the parent directory of the destination\n\t\t// path exists, in which case the copy may still succeed. If there is any\n\t\t// type of conflict (e.g., non-directory overwriting an existing directory\n\t\t// or vice versa) the extraction will fail. If the destination simply did\n\t\t// not exist, but the parent directory does, the extraction will still\n\t\t// succeed.\n\t\t_ = err // Intentionally ignore stat errors (see above)\n\t}\n\n\tvar (\n\t\tcontent         io.ReadCloser\n\t\tresolvedDstPath string\n\t\tcopiedSize      int64\n\t\tcontentSize     int64","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/cp.go#L369-L405","documentation":"Error \"destination \"%s:%s\" must be a directory or a regular file: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/container/cp.go:387 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}