Skip to content

Exporting and Importing Container Images

Andrew Pruski edited this page Oct 1, 2020 · 1 revision

In a previous wiki we pushed a custom SQL image to the Docker Hub.

However, what if that image contained sensitive information that we don't want people to see? Ok, we could have made the repository on the Docker Hub private but what if we don't want it in a public registry at all?

One option is to host your own container registry, but here we're going to go through exporting Docker images.

The image we're going to export is the image built in the previous wiki.

Here's the image: -

docker image ls

We can export that image by running: -

docker save sqlimage1 -o C:\temp\sqlimage1.tar

And there's the exported compressed image in the C:\temp folder! This can now be copied to another Docker host were it can be imported. Let's have a go at that on our local Docker host.

First thing is to remove the existing image: -

docker rmi sqlimage1

And now load the image from the file: -

docker load -i C:\temp\sqlimage1.tar

Once that's complete, confirm that the image is there: -

docker image ls

So if we want to make images available to other Docker hosts but we don't want to push to a remote repository we can export/images using these commands!