Tooling

A quick guide to portable Docker images

By Karl Hepworth26th July 2024

In today’s development landscape, when faced with additional security measures, you may need to transfer docker images from one registry to another without using a registry or the internet.

Did you know that Docker has a command that allows you to retrieve and store a Docker image as a file instead of keeping it in a registry? Docker has been able to do it for a while now, so there’s nothing stopping you from adding this to your workflow.

Diagram of the API workflow used in this blog post.

You might ask yourself, why is this helpful? However, consider what you might do if you encounter one of the following situations:

  • You need to transfer an image between two systems without using a registry.
  • You need to transfer an image between two systems without using the internet.
  • You want to archive a set of container images for potential later use.
  • You need to deploy an image to an offline cluster.

To save an image from your registry into a local file, you can use the docker save command. In the background, this will take each of the layers from the Docker image in your registry, package them up into an archive and output the file to the specified location. Many Docker-compatible tools such as Podman will also feature this command as well as a way to ensure cross-tooling can be used when needed.

$ docker save ${IMAGE_REFERENCE} -o ./docker-image.tar.gz
Writing manifest to image destination

To load a Docker image from a file into your registry, you can use the docker load command. What this does in the background is accept a packaged docker image created from the docker save command and unload it into the registry which is associated with the command being used. For example, you could use this process to load a Docker image into a Podman repository, or vice versa.

$ docker load -i ./docker-image.tar.gz
Loaded image: ${IMAGE_REFERENCE}

Gif of a verbose output when running these commands.

Final thoughts

Next time you want to share a container, perhaps you should consider this option. Having a cross-compatible Docker image file is a huge advantage that can be used and transferred as securely as any other file.

It’s a reliable and secure way to share your Docker images, which works with any OCI-compliant image and should be part of your backup and decommissioning processes.

Tags

tooling
development

Getting Started

Interested in a demo?

🎉 Awesome!

Please check your inbox for a confirmation email. It might take a minute or so.

🤔 Whoops!

Something went wrong. Check that you have entered a valid email and try submitting the form again.

We'll be in touch shortly.