Skip to content
This repository has been archived by the owner. It is now read-only.

added scpi command for copying images #3182

Closed
wants to merge 4 commits into from
Closed

added scpi command for copying images #3182

wants to merge 4 commits into from

Conversation

@marconi
Copy link

@marconi marconi commented Mar 11, 2016

This adds copy image (scpi) command for copying images from one machine to another. Helpful if you have huge image that pulling it again will take long or if you don't have internet access.

This is my first PR, any feedback would be appreciated. :)

Signed-off-by: Marconi Moreto Jr. <me@marconijr.com>
@nathanleclaire
Copy link
Contributor

@nathanleclaire nathanleclaire commented Mar 11, 2016

Very interesting. I guess this would allow for things like:

$ docker $(docker-machine config swarmnode-0) pull me/image
$ docker-machine scpi swarmnode-0:me/image swarmnode-1
$ docker-machine scpi swarmnode-0:me/image swarmnode-2

?

@marconi
Copy link
Author

@marconi marconi commented Mar 12, 2016

@nathanleclaire yep, sorry forgot to add an example. The syntax is basically:

docker-machine scpi [machine]:[image][:tag] [machine]

The tag is optional, if omitted, defaults to latest.

return host, image, nil
}

func generateSaveFilename(srcImage string) string {
Copy link
Contributor

@nathanleclaire nathanleclaire Mar 12, 2016

Could you make a test for this method as well please?

Copy link
Author

@marconi marconi Mar 12, 2016

@nathanleclaire yep, sure.

@nathanleclaire
Copy link
Contributor

@nathanleclaire nathanleclaire commented Mar 12, 2016

Cool use case -- I'm definitely interested. Why not use the Docker client API that machine has (this is how we manage swarm containers) directly instead of running docker commands over SSH?

Signed-off-by: Marconi Moreto Jr. <me@marconijr.com>
@marconi
Copy link
Author

@marconi marconi commented Mar 12, 2016

@nathanleclaire ah right, I think I can make that work. Will keep you posted.

@marconi
Copy link
Author

@marconi marconi commented Mar 12, 2016

@nathanleclaire I made some progress and I thought it even became simpler, let me know what you think. ;)

Signed-off-by: Marconi Moreto Jr. <me@marconijr.com>
@GordonTheTurtle
Copy link

@GordonTheTurtle GordonTheTurtle commented Mar 12, 2016

Please sign your commits following these rules:
https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "scpi" git@github.com:marconi/machine.git somewhere
$ cd somewhere
$ git rebase -i HEAD~4
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Ammending updates the existing PR. You DO NOT need to open a new one.

@GordonTheTurtle
Copy link

@GordonTheTurtle GordonTheTurtle commented Mar 12, 2016

Please sign your commits following these rules:
https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "scpi" git@github.com:marconi/machine.git somewhere
$ cd somewhere
$ git rebase -i HEAD~4
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Ammending updates the existing PR. You DO NOT need to open a new one.

1 similar comment
@GordonTheTurtle
Copy link

@GordonTheTurtle GordonTheTurtle commented Mar 12, 2016

Please sign your commits following these rules:
https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "scpi" git@github.com:marconi/machine.git somewhere
$ cd somewhere
$ git rebase -i HEAD~4
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Ammending updates the existing PR. You DO NOT need to open a new one.

Signed-off-by: Marconi Moreto Jr. <me@marconijr.com>
@nathanleclaire
Copy link
Contributor

@nathanleclaire nathanleclaire commented Mar 14, 2016

Hm, I think I have not been clear in communicating what I mean.

I mean that instead of shelling out to docker and docker-machine commands, it should use the built-in DockerClient from mcndockerclient module: https://github.com/docker/machine/blob/master/libmachine/mcndockerclient/docker_client.go#L11

Example usage in Swarm code here: https://github.com/docker/machine/blob/master/libmachine/provision/configure_swarm.go#L110

Can you update it to use that please?

Likewise, it should probably invoke scp directly. I'd suggest trying to use the existing docker-machine scp-related methods.

Thanks!

@marconi
Copy link
Author

@marconi marconi commented Mar 15, 2016

@nathanleclaire ah, I see. Sure will update, I was actually initially looking for something like it but wasn't sure how libmachine worked.

@marconi
Copy link
Author

@marconi marconi commented Mar 15, 2016

Only see one problem, the DockerClient doesn't have support for saving image. But the engine-api's client does, I saw some discussion with dockerclient moving to engine-api so its prolly not worth it adding an image save endpoint for it esp. since machine has this as well.

@marconi
Copy link
Author

@marconi marconi commented Mar 15, 2016

Closing this for now.

@marconi marconi closed this Mar 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants