Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow copying files/dirs to a container - simpler implementation #13125

Closed
wants to merge 1 commit into from

Conversation

cpuguy83
Copy link
Member

This is a simpler implementation of #10198

Does not support copying files between containers, though this could be done via:

$ docker cp <container>:<path> - | docker cp - <container2>:<path>

When copying from a container it will use GET /containers/<id>/copy, copying to a container would be POST /containers/<id>/copy?to=<path>
The postContainersCopy method will proxy to getContainersCopy for older API versions.

Closes #10198 #5846

// CmdCp copies files/folders from a path on the container to a directory on the host running the command.
//
// If HOSTDIR is '-', the data is written as a tar file to STDOUT.
// If LOCALPATH is '-' and the second arg, the data is written as a tar file to STDOUT.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/and/for/ on this line and next.

func (cli *DockerCli) CmdCp(args ...string) error {
cmd := cli.Subcmd("cp", "CONTAINER:PATH HOSTDIR|-", "Copy files/folders from a PATH on the container to a HOSTDIR on the host\nrunning the command. Use '-' to write the data as a tar file to STDOUT.", true)
cmd := cli.Subcmd("cp", "CONTAINER:PATH|LOCALPATH|- CONTAINER:PATH|LOCALPATH|-", "Copy files/folders to or from the container", true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Until we support container <-> container stuff it might be better to write this as something like:

[CONTAINER:PATH LOCALPATH|-] | [LOCALPATH|- CONTAINER:PATH]

@cpuguy83
Copy link
Member Author

ping @jlhawn

@cpuguy83 cpuguy83 force-pushed the simpler_copy_in branch 3 times, most recently from 4fa34a7 to 5e52b5e Compare May 11, 2015 20:33
@cpuguy83
Copy link
Member Author

Windows failure is due to some parsing issues in determining if the arg is a file path or a container+path. Will have to look more at it later.

But otherwise if we agree we want this functionality (and I think we have in the other PR) I'd like to get this moved to code-review.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83
Copy link
Member Author

Windows path errors all fixed.

@thaJeztah
Copy link
Member

@cpuguy83 what's the status on this, given that #13171 is also opened?

@crosbymichael
Copy link
Contributor

Lets not do competing implementations of exiting PRs. Lets start working with the original authors and contributors can collaborate on their forks and get the implementations worked out and have a joint PR opened that everyone is proud of.

@cpuguy83 cpuguy83 deleted the simpler_copy_in branch June 13, 2015 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants