docker/cli ยท error

destination "%s:%s" must be a directory

Error message

destination "%s:%s" must be a directory

What it means

Error "destination "%s:%s" must be a directory" thrown in docker/cli.

Source

Thrown at cli/command/container/cp.go:414

		// not exist, but the parent directory does, the extraction will still
		// succeed.
		_ = err // Intentionally ignore stat errors (see above)
	}

	var (
		content         io.ReadCloser
		resolvedDstPath string
		copiedSize      int64
		contentSize     int64
		sizeErr         error
	)

	if srcPath == "-" {
		content = os.Stdin
		resolvedDstPath = dstInfo.Path
		sizeErr = errors.New("content size not available for stdin")
		if !dstInfo.IsDir {
			return fmt.Errorf(`destination "%s:%s" must be a directory`, copyConfig.container, dstPath)
		}
	} else {
		// Prepare source copy info.
		srcInfo, err := archive.CopyInfoSourcePath(srcPath, copyConfig.followLink)
		if err != nil {
			return err
		}

		contentSize, sizeErr = localContentSize(srcInfo.Path)

		srcArchive, err := archive.TarResource(srcInfo)
		if err != nil {
			return err
		}
		defer srcArchive.Close()

		// With the stat info about the local source as well as the
		// destination, we have enough information to know whether we need to

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/container/cp.go:414 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/ca100d44cecf44e6.json. Report an issue: GitHub.