2026年11月12日
2026年11月12日
docker save and docker load: Save Docker Images to a tar File
This article is a localized edition of the Japanese original. Read the Japanese original
docker save writes Docker images to a single tar file, and docker load loads images from that tar file. Use them when you want to move an image to another machine without a registry (such as Docker Hub), bring an image to a server with no internet connection, or keep a specific version of an image on hand.
This article covers the basic usage, how tags, compression and multiple images are handled, and the difference from the similar docker export command. The options and behavior were checked against Docker's official reference as of November 2026.
Basics: save and load
Write a tar file with docker save
# Save by specifying name:tag
docker save -o nginx_1.27.tar nginx:1.27
# Without -o the output goes to standard output, so save it with a redirect
docker save nginx:1.27 > nginx_1.27.tar
-o (--output) sets the output file name. If the image doesn't exist locally, you get an error, so prepare it first with docker pull or docker build.
Load it with docker load
docker load -i nginx_1.27.tar
# Loaded image: nginx:1.27
# You can also load from standard input
docker load < nginx_1.27.tar
-i (--input) sets the file to load. When loading finishes, the image name and tag are shown after Loaded image:. Check that it appears in docker images.
Specify name:tag to keep the tag
If you save by image ID (the value in the IMAGE ID column of docker images), the tar file contains no image name or tag, and on the loading side the image has neither (it shows as <none>). In that case, name it with docker tag after loading.
# Loading an image that was saved by its ID
docker load -i image.tar
# Loaded image ID: sha256:...
# Add a name and tag again (you can use the first few characters of the ID shown)
docker tag 3b25b682ea82 myapp:1.0
If you save with "name:tag" from the start, such as myapp:1.0, you avoid this extra step.
Save multiple images together
You can list several images after docker save, and they are saved together in one tar file. Shared layers are stored only once, so the file can be smaller than saving them separately.
# Several images in one file
docker save -o webapp_images.tar myapp:1.0 nginx:1.27 mariadb:11.4
# One load registers every image in the file
docker load -i webapp_images.tar
If you give only a repository name without a tag (for example docker save -o all_nginx.tar nginx), every local tag of that repository is saved. Unwanted tags can make the file large, so naming the tags you need is easier to manage.
To save all the images used by Docker Compose, docker compose config --images lists the image names in use.
docker save -o compose_images.tar $(docker compose config --images)
Save compressed
The tar file written by docker save is not compressed. To reduce transfer or backup size, compress it with gzip or similar.
# Save while compressing with gzip
docker save myapp:1.0 | gzip > myapp_1.0.tar.gz
# Load it as is, still compressed
docker load -i myapp_1.0.tar.gz
docker load reads files compressed with gzip, bzip2, xz or zstd directly, so you don't need to decompress them first.
Save or load only a specific platform
If you work with images built for several CPU architectures (multi-platform images), --platform narrows the target. This option is available with Docker Engine API 1.48 and later (Docker Engine 28 and later).
# Save only the linux/amd64 variant
docker save --platform linux/amd64 -o myapp_amd64.tar myapp:1.0
# You can also narrow it when loading
docker load --platform linux/amd64 -i myapp_multi.tar
If the local image doesn't have the requested platform, you get an error such as no suitable export target found for platform.
Example: moving an image to another server
The flow for bringing an image to a server with no internet connection:
# 1. On a machine with internet access, pull and save
docker pull nginx:1.27
docker save nginx:1.27 | gzip > nginx_1.27.tar.gz
sha256sum nginx_1.27.tar.gz > nginx_1.27.tar.gz.sha256
# 2. Transfer the files (scp example)
scp nginx_1.27.tar.gz nginx_1.27.tar.gz.sha256 user@server:/tmp/
# 3. On the destination, check that the file is intact, then load it
cd /tmp
sha256sum -c nginx_1.27.tar.gz.sha256
docker load -i nginx_1.27.tar.gz
docker images nginx
Save an image that matches the CPU architecture (amd64, arm64, etc.) of the destination machine. You can check a local image's architecture with docker image inspect --format '{{.Architecture}}' nginx:1.27.
Difference from docker export / import
The similar commands docker export and docker import differ in what they target and what they keep.
| docker save / load | docker export / import | |
|---|---|---|
| Target | Images | A container (its file system) |
| Layers and history | Kept | Flattened into one file system; no history |
| Image name and tag | Kept (when saved as name:tag) | Not kept (set them at import) |
Settings such as CMD and ENV |
Kept | Not kept (set them at import with --change) |
| Main use | Moving an image as is to another environment | Extracting a container's contents as a file |
If you want to keep changes made inside a running container, you can also turn it into an image with docker commit and then save it with docker save. However, those changes aren't recorded in a Dockerfile and are hard to reproduce, so where possible, fixing the Dockerfile and rebuilding the image is easier to manage. For docker commit, see How to create an image from a container with docker commit.
Inspect the saved file
You can list the contents of the tar file with the tar command.
tar -tf nginx_1.27.tar | head
The saved file contains manifest.json, index.json and the layer data. The internal format of the tar file can differ between Docker versions, so don't edit its contents directly; always load it with docker load.
Things to watch
- The file contains the entire image: If you put configuration files or secrets (such as API keys) into the image, they can be extracted from the tar file too. Be careful where you store the file and who you share it with.
- Volume data is not included:
docker savesaves only images. Back up data stored in volumes, such as database data, separately. - Free disk space: Saving needs room for the tar file, and loading needs room for the image. For large images, check first with
df -h.
Summary
- Save with
docker save -o file.tar name:tagand load withdocker load -i file.tar. - Saving by image ID loses the name and tag, so specify "name:tag".
- List several images to put them in one file.
- Compress with
docker save name:tag | gzip > file.tar.gz.docker loadreads compressed files directly. - It is a different command from
docker export, which extracts a container's contents; save / load moves an image with its layers, tags and settings intact.
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)