Docker Image and Container Export/Import Commands Explained

301 words
2 minutes
Docker Image and Container Export/Import Commands Explained

Docker Image and Container Export/Import Commands Explained#

Docker provides several commands for exporting and importing images and containers, which can be confusing for beginners. This article breaks down the key differences.

docker export / docker import#

These operate on containers and export a snapshot of the container’s current filesystem.

Terminal window
# Export container snapshot
docker export container-id > snapshot.tar
# Import as an image
docker import snapshot.tar new-image-name:tag

Characteristics:

  • Only retains filesystem changes made from container start to export — discards history layers and metadata
  • Smaller file size (single filesystem layer)
  • Must specify a new image name and tag on import
  • Imported images require /bin/bash or another entrypoint on start

Use case: Creating base images. For example, start a container from ubuntu, install software, then export it as a distributable base image.

docker commit#

Operates on containers, saving modifications as a new image.

Terminal window
docker commit container-id new-image-name:tag

Common options:

  • -a: Author information
  • -m: Commit message
  • -p: Pause the container during commit

Characteristics:

  • Preserves the container’s writable layer plus the original image’s history layers
  • An N-layer image becomes N+1 layers after commit
  • Retains metadata like the entrypoint command

Use case: Quickly save changes from a debugging environment to create a reusable image.

docker save / docker load#

Operate on images, exporting the complete layer structure.

Terminal window
# Save an image
docker save -o image.tar image-name:tag
# Load an image
docker load -i image.tar

Characteristics:

  • Preserves the full layer structure and metadata
  • Larger file size than export (includes all history layers)
  • load cannot rename the image, while import can assign a new name

Use case: Offline image migration. On a server without internet, pull the image on a connected machine, save it, copy the archive, then load it on the target server.

Comparison Summary#

CommandTargetHistory LayersFile SizeRename on Import
docker exportContainer❌ Single layer onlySmall
docker commitContainer✅ Adds one layerMedium
docker saveImage✅ Full preservationLarge
docker loadImage✅ Full preservationLarge
docker importSnapshot file❌ Single layer onlySmall

Quick memory aid: save/load work with images, export/import work with containers, and commit is the bridge from container → image.

Support & Share

If this article helped you, please share or support!

Sponsor
Docker Image and Container Export/Import Commands Explained
https://blog.zinzin.cc/posts/docker-export-import-diff-en/
Author
gzdyj
Published at
2026-07-23
Profile Image of the Author
gzdyj
Code, life, and everything in between.
Announcement
Welcome to my blog! This is a sample announcement.
Categories
Tags
Latest Moments
Site Statistics
Posts
8
Categories
4
Tags
27
Total Words
13,116
Running Days
0 days
Last Activity
0 days ago
Site Info
Build Platform
GitHub Actions
Blog Version
Firefly v6.14.5
License
CC BY-NC-SA 4.0