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

CommandOptionDescription
save-o, --output stringWrite to the specified file; if omitted, output to STDOUT
save--platform stringsSave only the specified platforms, separated by commas, such as linux/amd64,linux/arm64/v8
load-i, --input stringRead from the specified tar archive; if omitted, read from STDIN
load--platform stringsLoad only the specified platforms
load-q, --quietSuppress load output
export-o, --output stringWrite the container filesystem to the specified file
import-c, --change listApply Dockerfile instructions to the created image
import-m, --message stringSet the commit message for the imported image
import--platform stringSet 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 -o writes 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 -i can read the gzip-compressed archive directly and load nginx:1.30-alpine.
  • After loading, docker images shows the image. Its DISK USAGE is 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 export writes the web container's filesystem to a tar archive, which docker import then uses to create the myweb:snapshot image.
  • The imported image still contains the files: specifying cat /usr/share/nginx/html/hi.txt reads hello.
  • .Config.Cmd for nginx:1.30-alpine contains nginx -g daemon off;, but .Config.Cmd for myweb:snapshot is an empty array, [].
  • Because the imported image has no default command, running docker run directly returns no command specified; you must specify a command when you run it.

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