docker-save
Save Docker images to a tar archive
TLDR
Save an image by redirecting stdout to a tar archive
Save an image to a tar archive
Save all tags of the image
Cherry-pick particular tags of an image to save
SYNOPSIS
docker save [OPTIONS] IMAGE [IMAGE...]
PARAMETERS
--output, -o string
Write the saved image archive to a specified file path, instead of STDOUT. This option is convenient for directing the output directly to a file.
DESCRIPTION
docker save is a fundamental command in Docker for packaging one or more Docker images into a single tar archive. This archive contains all the layers, metadata, and tags associated with the specified images, preserving their history and integrity.
Unlike docker export, which flattens a running container's filesystem into a tarball and loses image layers and metadata, docker save specifically targets images, making it ideal for scenarios where images need to be transferred between Docker daemons without relying on a Docker registry. This includes offline transfers, air-gapped environments, creating backups of images, or moving images to development/testing environments that might not have direct access to public or private registries.
The resulting tar archive can then be easily loaded onto another Docker host using the docker load command, making the images available for use. The command can output the archive to standard output, which can then be redirected to a file, or directly to a specified file using the --output option. It supports saving multiple images into a single archive, consolidating them for easier management and transfer.
CAVEATS
The saved archive can be very large, especially for images with many layers or large base images.
It saves images, not containers. To save a container's filesystem, use docker export.
The saved images do not include volumes or bind mounts unless they are part of the image's filesystem itself.
OUTPUT DESTINATION
By default, docker save writes the tar archive to standard output (STDOUT). This allows for flexible redirection, for example, piping the output directly to a file using `>` or to another command. Alternatively, the --output (or -o) option can be used to specify a direct file path for the archive, which is generally more convenient for single-file operations.
MULTI-IMAGE SAVING
The command supports saving multiple images into a single tar archive by listing them as arguments. For example, docker save -o all_my_images.tar image1:tag image2:tag image3 will bundle all specified images into one archive, simplifying transfer and management.
HISTORY
The docker save command has been a core utility in Docker since its early versions, providing a crucial mechanism for image portability outside of registry-based workflows. Its design reflects the need for offline distribution and migration of Docker images, which is essential for various enterprise and air-gapped environment deployments. It has remained largely stable in its functionality, focusing on its primary role of archiving images for transfer.