Contents
Docker Save Tutorial: Export and Load Images (save, load, export, import)
Use docker save and docker load to move images; docker export and docker import work with a container filesystem, and the resulting image may have different settings. For the basics of images, see Docker images.
Syntax
docker save [OPTIONS] IMAGE [IMAGE...]
docker load [OPTIONS]
docker export [OPTIONS] CONTAINER
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Options
| Command | Option | Description |
|---|---|---|
save | -o, --output string | Write to the specified file; if omitted, output to STDOUT |
save | --platform strings | Save only the specified platforms, separated by commas, such as linux/amd64,linux/arm64/v8 |
load | -i, --input string | Read from the specified tar archive; if omitted, read from STDIN |
load | --platform strings | Load only the specified platforms |
load | -q, --quiet | Suppress load output |
export | -o, --output string | Write the container filesystem to the specified file |
import | -c, --change list | Apply Dockerfile instructions to the created image |
import | -m, --message string | Set the commit message for the imported image |
import | --platform string | Set the platform if the server supports multiple platforms |
Examples
Save, gzip, and load an image
$ docker save -o nginx.tar nginx:1.30-alpine
$ ls -lh nginx.tar
-rw------- 1 root root 25.7M Oct 25 15:31 nginx.tar
$ docker save nginx:1.30-alpine | gzip > nginx.tar.gz && ls -lh nginx.tar.gz
-rw-r--r-- 1 root root 24.9M Oct 25 15:31 nginx.tar.gz
$ docker load -i nginx.tar.gz
Loaded image: nginx:1.30-alpine
$ docker images nginx
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
nginx:1.30-alpine 47928bf67eb6 93.5MB 27MB U
docker save -owrites an image to a tar archive; when used directly, the 25.7MB file contains the image data.- After gzip compression, this image is 24.9MB, only 0.8MB smaller than the original tar, so the compression effect is limited.
docker load -ican read the gzip-compressed archive directly and loadnginx:1.30-alpine.- After loading,
docker imagesshows the image. ItsDISK USAGEis 93.5MB, a different measurement from the archive size.
Import a filesystem with export and import
$ docker export web -o web-fs.tar && ls -lh web-fs.tar
-rw------- 1 root root 60.5M Oct 25 15:31 web-fs.tar
$ docker import web-fs.tar myweb:snapshot
sha256:56e3f92534ca8c5aedd8de576ae2433f1864d3d3b51de847a8dc8dd7d503da4d
$ docker run --rm myweb:snapshot cat /usr/share/nginx/html/hi.txt
hello
$ docker image inspect -f '{{.Config.Cmd}}' nginx:1.30-alpine
[nginx -g daemon off;]
$ docker image inspect -f '{{.Config.Cmd}}' myweb:snapshot
[]
$ docker run --rm myweb:snapshot
docker: Error response from daemon: no command specified
Run 'docker run --help' for more information
docker exportwrites thewebcontainer's filesystem to a tar archive, whichdocker importthen uses to create themyweb:snapshotimage.- The imported image still contains the files: specifying
cat /usr/share/nginx/html/hi.txtreadshello. .Config.Cmdfornginx:1.30-alpinecontainsnginx -g daemon off;, but.Config.Cmdformyweb:snapshotis an empty array,[].- Because the imported image has no default command, running
docker rundirectly returnsno command specified; you must specify a command when you run it.
Related chapters
Exercises
Exercise: Save nginx:1.30-alpine as a gzip-compressed archive, then load the image from that file.
Answer
docker save nginx:1.30-alpine | gzip > nginx.tar.gz
docker load -i nginx.tar.gz
FAQ
What is the difference between docker save and docker export?
docker save archives an image that you can later restore with docker load; docker export exports a container filesystem, and docker import uses it to create a new image.
How much space can gzip compression save on a docker save result?
In this example, the nginx:1.30-alpine tar file is 25.7MB, and the gzip-compressed file is 24.9MB, so the difference is limited.
Why does running docker run directly after docker import show no command specified?
The imported myweb:snapshot has an empty .Config.Cmd array, [], and no default command. Specifying cat /usr/share/nginx/html/hi.txt reads the file, but running it without a command displays no command specified.
Updated October 26, 2026