Save, Load and Transfer Docker Image

Rajesh
3 min readFeb 15, 2024

Kodekloud Docker Task

In Restricted environment, you don’t have internet access to download images.

You can convert your image in to tar file and copy it to restricted environment and extract it.

Suppose there are three hosts, In which 2 hosts(h2,h3) are restricted and only one host (h1) which have internet access and it can access registry to download images.

Host h1 will transfer the images to the other hosts(h2,h3) and host h2,h3 will load the images in to docker engine using the docker sub-commands save and load.

We are going to explore the docker sub-commands save and load in following kodekloud docker task.

Scenario

Solving the Task

  • First Login to the App Server 1
  • Check the docker images present in the host using
docker image ls
  • First, we need to save the image in tar format . So that we can transfer it to the App server 3.
  • Docker cli provides save sub-command to save the image in tar format.
docker image save news:datacenter -i news.tar
  • Now using SCP command to transfer the image in tar fomat to the App Server 3.
scp news.tar <user>@<ip/domain>:/home/<user>/news.tar
  • After successfully transferred to App Server 3, we need to load the image to docker.
  • Docker cli provides load sub-command to unzip the archive and load it to the docker engine.
docker image load -i news.tar
  • After loading, we will confirm it by listing the docker images in App Server 3.
  • Voila, successfully completed the task.
  • Thanks for viewing this blog. Have a great day !!

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

--

--