Thursday, July 16, 2020

How save and load docker images to offline servers

Description: It is difficult to provide internet in all servers in production environment. So without internet you can not pull image from docker hub. So in such cases you can create tar file of docker image and load it from tar file. 

Procedure:  In example I have 2 server AppServer1 and AppServer2. AppServer1 have internet and AppServer2 is behind the firewall without internet. So first we save docker image on AppServer1 and then copy to AppServer2. After copy to AppServer2 we load it from there. 

  • On AppServer1, we will pull httpd image from docker using below command
    AppServer1> docker pull httpd:latest
  • Once image pull from docker hub we save it to .tar.gz file in /images directory
    AppServer1> docker save httpd:latest > /images/httpdlatest.tar.gz
  • Now you need to copy httpdlatest.tar.gz file from AppServer1 to AppServer2  on /images location using SCP or any other way.
  • Once Copy process completed you need to load image from AppServer1 using below command
    AppServer2> docker load -i  /images/httpdlatest.tar.gz 
  • You can find the images using docker images command
    AppServer2> docker images
  • You can run image using below command in AppServer2
    AppServer2> docker run -d httpd:latest
    

No comments:

Post a Comment