Assume that there are two docker host machines A and B and there is a docker image, xyz on machine A. I would like to deploy it to machine B from machine A. How can I do it?
I know that it is possible to operate on containers remotely by setting DOCKER_HOST as below, but this seems to require the docker image xyz already exists on machine B. Also, creating a tar file from the image xyz and coping it to machine B, and then running it on machine B is another way to do it. I wonder if there is a way in which I can do it directly from machine A? Thanks!
docker -H "ssh://my-user@machine-b" run -i - t xyz
As David mentions, the standard way to move images is with a registry. You can self host (e.g. Docker's registry), use a SaaS offering like Hub, or one of the cloud vendors (e.g. ECR, GCR). The advantage of a registry over sending exports is layers are deduplicated, saving you bandwidth when your image only has minor changes between versions. This functionality is also built into the docker engine with the push and pull commands.
With the save and load method, you could do this in two commads, piping the output, but as mentioned before this will transfer all the layers even if you only have minor changes:
docker save ${image} | docker -H ssh://${user}@${host} load
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With