- Published on
Transferring Docker Images Between Machines Using docker save and ssh
- Authors
- Name
- Andreas Caldewei
This article presents a method for transferring docker images between machines.
Overview
Command
docker save IMAGE | ssh -C USERNAME@HOSTNAME docker load
This command saves the specified Docker image to a tar archive using the docker save command. It then transfers the tar archive over the network to a remote machine using ssh. Once the tar archive has been transferred, the docker load command is executed on the remote machine, which loads the image from the tar archive.
The -C flag passed to ssh enables compression, which can help reduce the amount of data transferred over the network.
Arguments
IMAGE
: The name or ID of the Docker image to save. This can be a specific version of the image, or it can be a repository name and tag in the name:tag format.USERNAME
: The username to use when connecting to the remote machine via ssh. This should be a valid user on the remote machine.HOSTNAME
: The hostname or IP address of the remote machine. This should be the address of the machine to which you want to transfer the image.
Options
C
: Enable compression when transferring data over the network. This can help reduce the amount of data transferred, which can be useful when transferring large files.
Notes
- This command requires that ssh and docker are installed on both the local and remote machines.
- This command will overwrite any image with the same name on the remote machine. If you want to preserve the existing image, you can either rename the image on the remote machine before running this command, or you can specify a different name for the image being transferred.