Exporting, Saving & Loading Images (docker save, load, export, import)
Move images offline with save/load and understand export/import filesystem archives.
In plain words
Use save/load to move complete OCI-adjacent Docker image artifacts offline; use export/import only for a deliberately flattened filesystem snapshot.
Think of it like…
save/load transports the whole edition with cover and printing plates; export/import photographs the current pages into a new book.
Where you’ve seen it
In practice, docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar is the concrete move for this job: move images offline with save/load and understand export/import filesystem archives. The release is not accepted until docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load confirms the result.
Words you’ll hear
- save/load
- The implementation control in
docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tarfor move images offline with save/load and understand export/import filesystem archives. - export/import
- The result to observe with
docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load, rather than infer from a successful command alone. - Offline
- The production boundary exposed when exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive.
Visual diagram
Theory & deep dive
save/load control path
The concrete mechanism is docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar. The observable result is docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load; if those disagree, inspect the runtime evidence before changing unrelated settings.
Move images offline with save/load and understand export/import filesystem archives. Keep save/load, export/import and Offline in the same deployment record so the intent and the observed state cannot drift apart.
docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar
docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load, not with command success alone.Offline failure boundary
A filesystem export loses the CMD, ENTRYPOINT, ENV, labels and layered history that make an image reproducible. Saving an image can also include several tags and parent blobs, so operators should inspect size and provenance. The narrow failure to design for is exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive.
Accept this compromise explicitly: save/load preserves image semantics but produces a large tar; registry transfer adds deduplication and access control but requires connectivity. The controlled check-docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load-also identifies the point where a different design is safer.
Exercise this failure safely: exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: A filesystem export loses the CMD, ENTRYPOINT, ENV, labels and layered history that make an image reproducible. Saving an image can also include several tags and parent blobs, so operators should inspect size and provenance.
- Intent
- save/load
When to use it & trade-offs
What it is
docker save serializes one or more images-including tags, manifests and parent layers-into a tar archive, and docker load restores that object set. docker export flattens one container filesystem while docker import creates a new image without original history, tags or layer sharing.
Why it matters: A filesystem export loses the CMD, ENTRYPOINT, ENV, labels and layered history that make an image reproducible. Saving an image can also include several tags and parent blobs, so operators should inspect size and provenance.
When to reach for it
- The fit is strongest for this job: move images offline with save/load and understand export/import filesystem archives. Pair it with
docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after loadin the runbook. - Production save/load changes should make export/import observable through
docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar, rather than trusting the runtime default. - Keep a rollback example for the case where exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive.
When to avoid or be careful
- Do not accept command success while the system can still fail by exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive.
- Avoid erasing Offline protection merely to dodge this cost: “save/load preserves image semantics but produces a large tar; registry transfer adds deduplication and access control but requires connectivity”.
- Do not replace the evidence path-
docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load-with a screenshot or a mutable tag.
docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar: practical choices
Strengths: docker save serializes one or more images-including tags, manifests and parent layers-into a tar archive, and docker load restores that object set. docker export flattens one container filesystem while docker import creates a new image without original history, tags or layer sharing.
Watch out: save/load preserves image semantics but produces a large tar; registry transfer adds deduplication and access control but requires connectivity.
Strengths: It can begin with docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar and fewer surrounding controls.
Watch out: It silently accepts exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive, which makes the result hard to reproduce after promotion.
Strengths: A filesystem export loses the CMD, ENTRYPOINT, ENV, labels and layered history that make an image reproducible. Saving an image can also include several tags and parent blobs, so operators should inspect size and provenance.
Watch out: The platform adds an ownership and debugging layer; retain docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load as the direct check.
Interview signals & numbers to know
When this topic comes up
- docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar
- docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load
- Failure signature: exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive
- Trade-off: save/load preserves image semantics but produces a large tar; registry transfer adds deduplication and access control but requires connectivity.
Benchmarks & rules of thumb
- 2 image-preserving commands
- save and load
- 2 flattening commands
- export and import
- 0 Docker config entries
- guaranteed by container export alone
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.taras proof and skippingdocker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load. - Exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive
- Optimizing save/load without accepting that save/load preserves image semantics but produces a large tar; registry transfer adds deduplication and access control but requires connectivity.
Likely interviewer follow-ups
- Why does
docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.taraddress save/load here rather than through application code? - How would you distinguish healthy export/import from the failure “exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive” using
docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load? - When would this trade-off-“save/load preserves image semantics but produces a large tar; registry transfer adds deduplication and access control but requires connectivity”-justify a different Offline design?
docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar-and one proof-docker image inspect acme/api:2.1.4 --format {{json .Config.Cmd}} and compare RepoTags plus layer count before and after load. Then name the boundary: exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Exporting, Saving & Loading Images (docker save, load, export, import) with generative AI interview Q&A and hands-on practice.