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 docker cp to copy host->container, container->host, container->container #6580
Conversation
return fmt.Errorf("Missing parameter") | ||
} | ||
|
||
resource := r.Header.Get("Resource") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to use the header for this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, do you have another idea ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the url?
Wouldn't it be neater (and cleaner) to do this with interfaces? You take the two arguments and convert them to types which fulfill interfaces that allow you to copy to and from them. |
I'm not very sure how it must working :) But for now it is very strange behavior as for me:
Also
does nothing for me :( |
pathSrc = cmd.Arg(0) | ||
pathDst = cmd.Arg(1) | ||
) | ||
if len(infoSrc) != 2 && len(infoDst) != 2 { | ||
return fmt.Errorf("Error: Path not specified") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be sort of "Wrong path format" and usage print.
Also for
And there is no check about files existence on host. |
} | ||
defer data.Close() | ||
switch method { | ||
case "OUT": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have two separate jobs for this cases?
Also word copy in method names was pretty confusing for me when I read code. Maybe we should use sort of |
@LK4D4 "And there is no check about files existence on host." ? |
|
@LK4D4 addressed most of the comments, regarding the failures I think we have an issue with files in the Archive package: https://github.com/vieux/docker/compare/dotcloud:master...vieux:tar_untar_file?expand=1 |
neat! a pony, and in my favourite colour too!! |
@vieux remove "file" from the path.Join in both the Tar and Untar function calls. |
Also, we should check autocomplete. Doesn't work in zsh for me at least. |
@LK4D4 feel free to submit a PR to my branch to update all the completion scripts..:) |
Autocomplete here is already kind of annoying since we don't have something |
@tianon ah, also there was two PRs with |
Isn't completion handled by the bash/zsh/fish scripts ? |
Yeah, I can PR an update to bash, but I'm not zsh or fish fluent so can't help much there. |
errorOut(err, t, fmt.Sprintf("failed to cp to the container: %v", err)) | ||
} | ||
|
||
/* TODO: allow overriding files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @tiborvass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated. 2 things for @tiborvass .
|
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
Fix cp host container to root
@LK4D4 can you retry now ? |
@vieux yup, I'll try on weekend |
After first command |
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Update bash-completion for bidirectional "docker cp"
@@ -994,6 +994,28 @@ func postContainersCopy(eng *engine.Engine, version version.Version, w http.Resp | |||
return nil | |||
} | |||
|
|||
func putContainersCopy(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error { | |||
if vars == nil { | |||
return fmt.Errorf("Missing parameter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe be more explicit in the error message about which parameter you're expecting.
This is sweet. |
… multiple entries in the archive stream Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
Closing for now, will reopen when we figure out the tar stuff |
Just curious, if windows is ever supported would things like: |
Ignoring the client command line syntax for a moment, and just focusing on the REST API, I was wondering what people thought about cleaning it up a bit? As I mentioned in https://groups.google.com/forum/#!topic/docker-dev/TmaCiWIEyVk using POST to retrieve a file feels a bit odd and having the path to the file be in the http body is a bit limiting. I was wondering what people thought about adding new APIs that were a bit more natural/RESTy, in particular: I'd be interested in working on a PR on this but only if there's interest - aside from the container->container copy, I think most of the code is already there and its just minor edits to expose it slightly differently. The old APIs can stick around and be deprecated. Thoughts? |
@vieux - was wondering if you had any feedback on this? I'm most interested in the support for checking to see if a file is present in a container - the other stuff around it, while interesting, isn't as critical to my needs right now. I'd really like to submit a PR for this "does a file exist" feature but don't want to code it up until I get a sense for the direction people would like to see it go. . |
@duglin is right! But we also like the feature to copy the file from host to container. Maybe we don't need to copy from container to container because we can do it by the existing methods. |
Closes #5846
This allows:
docker cp <container_id>:/path path
docker cp path <container_id>:/path
docker cp <container_id>:/path <container2_id>:/path
With container to container, to keep the code simple (for now?) the content goes through the client's fs.
Needs
API
bump & docThis one needs a lot of testing @crosbymichael @tiborvass @unclejack @LK4D4