Suppose there are two machines, and . There is a Docker image in that has to be sent to . Here, we shouldn’t use a Docker repository to store the image from and pull the image to from the repository.
The solution to this problem lies in using the following commands:
docker savesshdocker loadThese are the steps we follow to move a Docker image between hosts:
Step 1:
We use the docker save command to create a tar file of the docker image in machine .
docker save -o image.tar docker_image_name
Then, we create the image.tar file in machine .
Step 2:
We use the ssh command to send the tar file from machine to machine .
The syntax for the scp command is as follows:
scp [source content location] [destination content location]
scp /users/X/Desktop/image.tar Y@www.server2.com:/users/Y/Downloads
Now, the tar file is in machine .
Step 3:
We use the docker load command to load the tar file.
cat ./image.tar | docker load