DEV Community

Cover image for How to Export & Import Docker Image
Ahmad Mujahid
Ahmad Mujahid

Posted on

1

How to Export & Import Docker Image

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Here are the explanation for this command. In general the command is like this :

$ docker export <image-name> > <output-name>.tar
Enter fullscreen mode Exit fullscreen mode
  • 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 .tar format.

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
Enter fullscreen mode Exit fullscreen mode

In general, the command is like this :

$ docker load -i <tar-file>.tar
Enter fullscreen mode Exit fullscreen mode

If the import / load is successful, you will see the image if you run docker images command.

That's all, very simple :)


External sources :

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more