Save, Load and Transfer Docker Image

Save, Load and Transfer Docker Image

·

2 min read

In this tutorial, we'll guide you through the process of saving a Docker image, transferring it to another server, and loading it on that server. We'll use App Server 1 to save the image named ecommerce:datacenter, transfer it to App Server 2, and load it with the same name and tag.

Prerequisites:

  • Access to both App Server 1 and App Server 2.

  • Docker installed and running on both servers.

Task Overview:

The task involves the following steps:

  • Saving the Docker image ecommerce:datacenter on App Server 1 as an archive.

  • Transferring the image archive to App Server 2.

  • Loading the image archive on App Server 2 with the same name and tag.

1. Saving the Docker Image on App Server 1:

First, SSH into App Server 1.

ssh user@app_server1_ip

Replace user with your username and app_server1_ip with the IP address of App Server 1.

Next, save the Docker image ecommerce:datacenter as an archive using the following command:

docker image save ecommerce:datacenter > ecommerce.tar

This command saves the Docker image as an archive named ecommerce.tar.

2. Transferring the Image Archive to App Server 2:

Now, transfer the ecommerce.tar archive to App Server 2 using the scp command. Execute the following command from your local machine:

scp path/to/ecommerce.tar user@app_server2_ip:/home/

Replace path/to/ecommerce.tar with the local path to the archive file, user with your username, app_server3_ip with the IP address of App Server 2.

3. Loading the Image Archive on App Server 2:

SSH into App Server 2.

ssh user@app_server2_ip

Once logged in, load the Docker image archive ecommerce.tar using the following command:

docker load < ecommerce.tar

This command loads the Docker image from the archive file into the local Docker image repository on App Server 2.

Conclusion:

In this tutorial, you learned how to save a Docker image as an archive, transfer it to another server, and load it on that server. By following these steps, you can efficiently share Docker images between servers, enabling seamless deployment and testing of applications across different environments.