Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 38/ 160
02. Dockerfiles & Image Building

Exporting, Saving & Loading Images (docker save, load, export, import)

Move images offline with save/load and understand export/import filesystem archives.

Intermediatesave/load · export/import3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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.tar for 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

Loading interactive 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.

Concrete save/load setup

docker save -o acme-api-2.1.4.tar acme/api:2.1.4; docker load -i acme-api-2.1.4.tar

Key takeaway: Prove export/import with 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.

Deliberate failure test

Exercise this failure safely: exporting a running container as an image backup and expecting environment configuration, entrypoint or history to survive.

Key takeaway: save/load preserves image semantics but produces a large tar; registry transfer adds deduplication and access control but requires connectivity.

How it works, step by step

Step 1 of 4
Design

1. 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.

Use save/load to move complete OCI-adjacent Docker image artifacts offline; use export/import only for a deliberately flattened filesystem snapshot.
Key numbers at this step
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 load in 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

Explicit save/load
Best for: Move images offline with save/load and understand export/import filesystem archives, with a reviewed runbook.

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.

Ambient default
Best for: Short-lived export/import experiments with low blast radius.

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.

Managed Offline
Best for: Teams that centralize Offline policy across many workloads.

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.tar as proof and skipping docker 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.tar address 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?
Interview tip: Give one concrete operation-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

Loading quiz

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.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Adding Container Health Checks (HEALTHCHECK Instruction)
Next topic
Inspecting Image History & Layer Sizes (docker history, dive)