Skip to content

Conversation

@sondavidb
Copy link
Contributor

Closes #4691

This PR should allow support for the following in container cp:

  • Specifying - in src to allow streaming the contents of a tarball into a container.
  • Specifying - in dst to allow streaming the contents of a container into a tarball that is written to stdout

- `nerdctl cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-`
- `nerdctl cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH`

Using `-` as the `SRC_PATH` streams the contents of `STDIN` as a tar archive. The command extracts the content of the tar to the `DEST_PATH` in container's filesystem. In this case, `DEST_PATH` must specify a directory. Using `-` as the `DEST_PATH` streams the contents of the resource as a tar archive to `STDOUT`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, copied this exact wording from https://docs.docker.com/reference/cli/docker/container/cp/#corner-cases. LMK if this is a problem in any way.

@sondavidb
Copy link
Contributor Author

sondavidb commented Jan 16, 2026

Will get to adding testing tomorrow. Having some trouble adding tests to the existing testing suite for now.

Signed-off-by: David Son <davbson@amazon.com>
@sondavidb sondavidb force-pushed the add-container-cp-tarballs branch from 5bd5c65 to 91f3775 Compare January 24, 2026 04:16
@sondavidb
Copy link
Contributor Author

I was very optimistic about the testing suite, stuffing the test cases in there took a lot of effort. This suite could certainly split up some functions (the amount of if statements in here is hard to keep track of, to say the least...)

In any case, tests passed locally so hoping this should be good to go 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support stdin/stdout streaming (-) in nerdctl cp

1 participant