Quick Answer
# Export an image to a tar file
docker save -o myimage.tar myimage:latest
# Load an image from a tar file
docker load -i myimage.tar
What You’re Trying to Do
You need to move a Docker image into an offline, air-gapped environment, or copy it to another server without going through Docker Hub or a private registry. That’s exactly what docker save and docker load are for.
docker push/docker pull move images through a registry. docker save/docker load move them as a plain tar file instead — handy for closed networks, staging environments, or anywhere a registry isn’t available or desirable.
Environment
- Docker: verified on 20.10 and later
- OS: Linux / macOS / Windows (WSL2)
Solution
1. Export an Image to a tar File (docker save)
docker save -o myimage.tar myimage:latest
You can also stream to stdout and compress with gzip:
docker save myimage:latest | gzip > myimage.tar.gz
Multiple images can be bundled into a single tar file:
docker save -o images.tar myimage:latest another-image:v1
2. Transfer the File to Another Machine
scp myimage.tar user@remote-host:/tmp/
A USB drive or other physical media works just as well.
3. Load the Image from the tar File (docker load)
docker load -i myimage.tar
Compressed files can be loaded directly:
docker load -i myimage.tar.gz
You can also load from stdin:
cat myimage.tar | docker load
4. Verify the Loaded Image
docker images
The tag from docker save is preserved, so you can run it right away with the original name, e.g. docker run myimage:latest.
5. Exporting a Running Container’s Filesystem (docker export)
If you only need a running container’s filesystem — not the full image — use docker export instead.
docker export <container-name> -o container.tar
Load a tar file created by docker export with docker import, but note that layer history and metadata like CMD/ENTRYPOINT are not preserved.
docker import container.tar myimage:imported
Common Errors
open myimage.tar: no such file or directory
The path passed to docker load -i is wrong, or it’s pointing somewhere other than where docker save wrote the file.
ls -la myimage.tar
docker load -i ./myimage.tar
Error processing tar file(exit status 1): unexpected EOF
The transfer was interrupted and the tar file is corrupted. Re-transfer with scp or rsync, and compare file size or sha256sum before and after.
sha256sum myimage.tar
docker images Shows Nothing After docker load
docker load may have run against a different Docker daemon (a different context or remote host). Check the active context.
docker context ls
docker context use default
no space left on device
The destination has run out of disk space while extracting the tar file. Check usage with docker system df and clean up unused images/containers.
docker system df
docker system prune
FAQ
Q: What’s the difference between docker save and docker export?
docker save exports the full image, including its layer structure and metadata (CMD/ENTRYPOINT, environment variables, etc.). docker export flattens a running container’s filesystem into a single layer with no metadata. Use docker save when you want to migrate the image as-is.
Q: How do I reduce the tar file size?
Compress it with docker save myimage | gzip > myimage.tar.gz. Trimming unnecessary layers with a multi-stage build also shrinks the underlying image size.
Q: Can I change the tag when running docker load?
docker load has no option to rename the tag. Re-tag it afterward with docker tag.
docker tag myimage:latest myimage:v2
Q: Which is better, a registry or save/load?
For ongoing image distribution, a registry (Docker Hub, ECR, GCR, etc.) with push/pull is easier to manage. For offline environments or one-off transfers, save/load is the quicker option.
Q: If I bundle multiple images into one tar, can I load them individually?
docker load always loads every image in the tar file at once. If you need to load images individually, run docker save separately for each one.
Related Articles
Recommended VPS / Hosting
Build your production environment on a reliable VPS: