docker export / docker import
docker export
Exports a container’s filesystem as a tar archive on STDOUT. Import it with docker import. Only the filesystem is exported — metadata such as exposed ports, CMD, and ENTRYPOINT is lost. Volumes are not included.
docker import
Creates an image from a tar archive produced by docker export. The archive can be a file path, URL, or STDIN (with -). Returns the new image ID. You can tag it as repository:tag. Import produces a single-layer image with no Docker config (ports, CMD, etc.).
Flatten an image to one layer:
docker export 35d171091d78 | docker import - flatten:test
docker history flatten:test
docker save / docker load
docker save
Saves named images or repositories to a tar on STDOUT (use -o for a file). Reference images by ID or repository:tag. If you pass only a repository name, all tagged images in that repo are saved, not just latest. Often paired with docker load for backup or air-gapped distribution.
Example:
docker save -o /tmp/redis.tar redis:latest
docker rmi redis:latest
docker load -i /tmp/redis.tar
docker images redis
docker load
Loads images from a tar on STDIN. The archive can contain multiple images and tags. Unlike import, metadata and history are preserved. Archives from docker save make save/load a viable registry alternative for backups and offline transfer.
Related topics
- Manual image creation
—
docker commit - Creating images — Dockerfile builds
Andrew Dorokhov