We can always pull docker images from docker registry. But, sometimes we need to share our images manually. In this post, I will share you how to import and export docker images.
Export Docker Image
Let say we have these two docker images in my local docker
$ docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
mysql         5.7       547b3c3c15a9   4 weeks ago     501MB
postgres      12        d480c196f9b0   3 months ago    405MB
We want to export postgres docker image. To do that, we can do that using docker export command like this :
$ docker export postgres > postgres.tar
Here are the explanation for this command. In general the command is like this :
$ docker export <image-name> > <output-name>.tar
- change 
<image-name>with the image that you want to export - change 
<output-name>in to the output name you intended. The output file will be on.tarformat. 
Import Docker Image
Let say you want to import / load the exported docker image file (the .tar file). You can use docker load command like this :
$ docker load -i postgres.tar
In general, the command is like this :
$ docker load -i <tar-file>.tar
If the import / load is successful, you will see the image if you run docker images command.
That's all, very simple :)
External sources :
              
    
Top comments (1)
Seems you are wrong. Docker export is to export container filesystem. Docker load is to load docker image. The proper command to export docker image for being loaded further is: docker save.