How to Import and Export Docker Images for Migration
This guide explains how to migrate Docker images by using the docker load/save commands for image‑level import/export and the docker import/export commands for container‑level import/export, detailing each command's options and providing concrete examples.
Import and Export via Image (docker load / docker save)
Docker provides load and save commands to import and export images as tar archives.
docker load reads an image from a tar file or STDIN. docker load --help Usage: docker load [OPTIONS] Key options: -i, --input string – read from a tar archive file instead of STDIN. -q, --quiet – suppress output.
Example importing from a file: docker load -i nginx.tar Or using a pipe: docker load < nginx.tar Both forms import the image together with its metadata and tag information.
docker save writes one or more images to a tar archive (STDOUT by default). docker save --help Usage: docker save [OPTIONS] IMAGE [IMAGE...] Key option: -o, --output string – write to a file instead of STDOUT.
Example saving to a file: docker save -o nginx.tar nginx:latest Or redirecting output: docker save > nginx.tar nginx:latest Here nginx.tar is the target file and nginx:latest is the source image (name:tag).
Import and Export via Container (docker import / docker export)
Docker also supports importing and exporting a container's filesystem.
docker import creates an image from a tarball or URL. docker import --help Usage:
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]Key options: -c, --change list – apply Dockerfile instructions to the created image. -m, --message string – set a commit message for the imported image.
Example importing a tar file as an image named nginx:imp : docker import nginx-test.tar nginx:imp Or using a pipe: cat nginx-test.tar | docker import - nginx:imp docker export streams a container's filesystem as a tar archive. docker export --help Usage: docker export [OPTIONS] CONTAINER Key option: -o, --output string – write to a file instead of STDOUT.
Example exporting a container named nginx-test to nginx-test.tar : docker export -o nginx-test.tar nginx-test Here -o specifies the output file, nginx-test.tar is the target file, and nginx-test is the source container name.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ZhiKe AI
We dissect AI-era technologies, tools, and trends with a hardcore perspective. Focused on large models, agents, MCP, function calling, and hands‑on AI development. No fluff, no hype—only actionable insights, source code, and practical ideas. Get a daily dose of intelligence to simplify tech and make efficiency tangible.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
