Exporting and Importing Container Images - dbafromthecold/SqlServerAndContainersGuide GitHub Wiki

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

/images/4.BuildingACustomImage/ExportingDockerImages/1.ViewImages.png

We can export that image by running: -

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

/images/4.BuildingACustomImage/ExportingDockerImages/2.ExportImage.png

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

/images/4.BuildingACustomImage/ExportingDockerImages/3.DeleteImage.png

And now load the image from the file: -

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

/images/4.BuildingACustomImage/ExportingDockerImages/4.LoadImage.png

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

docker image ls

/images/4.BuildingACustomImage/ExportingDockerImages/5.ViewImages.png

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!