---
title: "Moving Docker Images Offline with docker save and docker load"
date: "2026-11-18T09:30:00+07:00"
description: "Exporting and importing container images across air-gapped environments, USB drives, and isolated networks using docker save, docker load, and compression streams."
author: "AI Assistant"
image: "https://blog.redlinesoft.net/images/post/moving-images-offline-docker-save-load.jpg"
alt: "Workflow illustration showing docker save tar archive transferred offline and restored with docker load"
tags: ['docker', 'cli', 'air-gapped', 'sysadmin']
---

In enterprise environments, high-security data centers, defense installations, and edge sites, host nodes are often completely isolated from the public Internet ("air-gapped networks"). In these environments, pulling images directly from registries like Docker Hub via `docker pull` is impossible.

The Docker CLI provides `docker save` and `docker load` to bundle container images—complete with layer history, tags, and execution metadata—into transportable tar archives.

In this tutorial, we will learn how to export images, compress archives efficiently, transfer them to remote hosts over SSH pipes, and restore them cleanly.

## `docker save` vs `docker export`: The Crucial Difference

Before diving into syntax, it is vital to understand how `docker save` differs from `docker export`:

```text
+-----------------------------------------------------------------------------------+
| docker save <image>                                                               |
|   - Exports an IMAGE (all layers, parent history, tags, entrypoint metadata)     |
|   - Restored using: docker load                                                   |
+-----------------------------------------------------------------------------------+
| docker export <container>                                                         |
|   - Exports a CONTAINER filesystem snapshot (flat filesystem tar, no history)     |
|   - Restored using: docker import                                                 |
+-----------------------------------------------------------------------------------+
```

Always use `docker save` when your goal is moving full container images between Docker hosts.

## Exporting Images with `docker save`

To package one or more local images into an uncompressed tar archive:

```bash
docker save -o myapp-1.0.tar myapp:1.0
```

### Exporting Multiple Images Into a Single Archive

You can package several images or multi-service dependencies (e.g., app + database) into a single tar file:

```bash
docker save -o full-stack.tar redis:7-alpine postgres:15-alpine nginx:latest
```

## Optimizing File Size with Compression

Uncompressed container image tars can quickly reach gigabytes in size. You can pipe `docker save` directly into `gzip`, `pigz`, or `zstd` to shrink the archive during creation:

```bash
# Compress with standard gzip
docker save myapp:1.0 | gzip > myapp-1.0.tar.gz

# Parallel compression with pigz (much faster on multi-core CPU hosts)
docker save myapp:1.0 | pigz > myapp-1.0.tar.gz
```

## Transferring Images Directly Over SSH Pipes

If you have SSH access to an air-gapped host (or remote jump server), you can stream `docker save` directly to `docker load` without creating an intermediate tar file on your local disk:

```bash
docker save myapp:1.0 | gzip | ssh user@remote-node.internal "gunzip | docker load"
```

This single command exports the local image, compresses it on the fly, streams it across SSH, uncompresses it on the remote machine, and registers it into the remote Docker daemon!

## Importing Images with `docker load`

On the destination host, restore the image archive into the local Docker graph store:

```bash
# Load from uncompressed tar file
docker load -i myapp-1.0.tar

# Load directly from compressed file stream
gunzip -c myapp-1.0.tar.gz | docker load
```

Sample output:
```text
Loaded image: myapp:1.0
Loaded image: redis:7-alpine
```

After loading, running `docker image ls` confirms that all original tags, manifest digests, and execution metadata (CMD, ENTRYPOINT, ENV) are fully preserved.

## Inspection of Saved Tar Archives

If you untar a `docker save` archive manually (`tar -tvf myapp-1.0.tar`), you will see the exact internal layout of OCI/Docker image storage:

```text
manifest.json      # Maps tags to layer tarballs and config JSON
config.json        # Image execution config (ENV, ENTRYPOINT, labels)
blobs/sha256/...   # Individual compressed layer tars
repositories       # Legacy tag mapping
```

## Summary & Command Reference

| Task | Command Example |
| :--- | :--- |
| **Save Single Image** | `docker save -o app.tar myapp:v1` |
| **Save Multiple Images** | `docker save -o stack.tar redis:alpine postgres:alpine` |
| **Save + Gzip Compress** | `docker save myapp:v1 \| gzip > app.tar.gz` |
| **Stream Live over SSH** | `docker save myapp:v1 \| ssh host "docker load"` |
| **Load Image Archive** | `docker load -i app.tar` |

Using `docker save` and `docker load` ensures seamless offline image distribution while maintaining 100% build history and metadata fidelity.
