Hi everyone, today i would like to share a good trick that already know and not for others, it is how to save and reload pulled Docker images directly from the repository? Because when you pull image from repository is not persisted directly on your local storage then impossible to move it from one computer to another in offline mode.
Recently i had experiencing an issue and i was obliged to reset Docker, hence i have lost all images.
With this problem, I have looking for a solution on the web and I found on Docker documentation the save and load command, see now how it works!
Let us go!
Before to save image and after load it, you will have to pull the image first from the concerned registry famously on DockerHub, here we will take the example of
docker pull nginx:latest
Download finished successfully type this command to check if it figure in the image list:
This is the result :
Save docker image
After that to save or persist the nginx image on a local storage, start by positioning yourself in the folder that will contain your image in my case is the folder DockerImages and those with the command
cd, and thereafter type:
docker save nginx > nginx.tar ou
docker save –output nginx.tar nginx
Wait a few minutes in relation to the size of your image and then check in your folder, normally you should find your image.
Load Docker image
Already having an image in .tar format, you can reintegrate it on any machine in offline mode instead of redoing a registry pull.
In addition, to load an image into your Docker, you should first place yourself in the folder containing your image and then type the command:
docker load < nginx.tar ou
docker load –input nginx.tar
This is a simple tip but very useful in most cases, more!