Cloud Native 7 min read

How to Migrate Docker Images, Containers, and Volumes Without a Registry

Learn practical, non‑standard techniques for migrating Docker images, containers, and data volumes—including using docker save/load, export/import, and volume backup/restore with tar—especially useful in offline or tightly controlled production environments lacking a registry.

Open Source Linux
Open Source Linux
Open Source Linux
How to Migrate Docker Images, Containers, and Volumes Without a Registry

Image

Image migration is suitable for offline environments. Usually an offline Docker registry is built, but when no network or internal registry exists, the only option is to transfer images directly.

Save

# use stdout
docker save alpine > /tmp/alpine.tar
# or write to a file directly
docker save alpine -o /tmp/alpine.tar

Using the -o form is recommended because the stdout method may fail in scenarios such as remote execution via ssh.

Load

# use stdout
docker load < /tmp/alpine.tar
# or read from a file directly
docker load -i /tmp/alpine.tar

Container

Container migration is useful for services already in production that have complex state and cannot be started from scratch. The migration package includes the image.

Export

Prepare a running container and modify its filesystem.

$ docker run --rm -d --name test alpine tail -f /dev/null
9232f0c1dafe...
$ docker exec test touch proof
$ docker exec test ls -hl proof
-rw-r--r-- 1 root root 0 Nov 20 14:33 proof

# export the container
docker export test -o test.tar

Import

Stop the container before importing.

$ docker kill test
test
# import the tar as a new image
docker import test.tar test-img
sha256:e03727...

Note that docker import creates an image equivalent to a docker commit, which is not a recommended practice; therefore container export/import is not ideal.

Verify the imported image:

$ docker run --rm -d --name test test-img tail -f /dev/null
ee29cb63...
$ docker exec test ls -hl proof
-rw-r--r-- 1 root root 0 Nov 20 14:33 proof

Volume

Volume migration is more cumbersome because Docker provides no simple official solution.

Directly accessing Docker’s volume directory (e.g., /var/lib/docker/volumes/) and packaging it works but is a poor approach. The recommended method is to use a helper container to tar the volume and copy it out.

Backup

Create a volume and add a test file.

$ docker run --rm -d --name test -v test-vol:/data test-img tail -f /dev/null
f4ff81...
$ docker exec test touch /data/proof
$ docker exec test ls -hl /data/proof
-rw-r--r-- 1 root root 0 Nov 20 14:40 proof

Backup the volume:

$ docker run --rm -v test-vol:/volume -v $PWD:/backup alpine tar cvf /backup/backup.tar volume
volume/
volume/proof

Alternatively, docker cp can copy the tar file, but it may affect a running container.

Restore

Remove the old container and volume, then restore:

$ docker kill test
$ docker volume rm test-vol
test-vol
$ docker run --rm -v test-vol:/volume -v $PWD:/backup alpine tar xf /backup/backup.tar

Verify the restored data:

$ docker run --rm -v test-vol:/data alpine ls -ahl /data
total 8
drwxr-xr-x 2 root root 4.0K Nov 20 14:48 .
drwxr-xr-x 1 root root 4.0K Nov 20 14:50 ..
-rw-r--r-- 1 root root 0 Nov 20 14:40 proof

Conclusion

The three methods described are non‑standard. Image transfer should rely on an internal Docker registry rather than tar files, except for special cases like P2P distribution of large images. Containers should be considered disposable—restarting or recreating them does not affect functionality, and any persistent state should be externalized. Volume migration can be automated with proper plugins.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockeroffline deploymentimage migrationVolume BackupContainer Export
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.