Docker Certified Associate Exam Course
Docker Image Management
Save and Load Images
Learn how to export Docker images and containers to tar
archives, move them into air-gapped or restricted environments, and load or import them back into Docker without direct internet access.
Table of Contents
- Exporting and Transferring Docker Images
- Exporting a Container Filesystem and Importing as an Image
- Docker CLI Reference
- Links and References
1. Exporting and Transferring Docker Images
When you cannot pull directly from Docker Hub (for example, in a restricted environment), follow these steps:
Step-by-Step Guide
- Pull the desired image on an internet-connected host:
docker pull alpine:latest
- Save the image into a tarball:
docker image save alpine:latest -o alpine.tar
- Transfer
alpine.tar
to the target system (USB drive, SCP, shared NFS, etc.). - Load the tarball on the restricted host:
You should see output similar to:docker image load -i alpine.tar
beee9f30bc1f: Loading layer [==================>] 5.862MB/5.862MB Loaded image: alpine:latest
- Confirm the image is available locally:
Example output:docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE alpine latest a187dde48cd2 4 weeks ago 5.6MB
Note
Always verify you’re using the correct <repository>:<tag>
when saving and loading images to avoid version mismatches.
Warning
Ensure you have sufficient disk space on both source and target systems before exporting large images.
2. Exporting a Container Filesystem and Importing as an Image
You can snapshot a running container’s filesystem and convert it into a new Docker image:
- Export the container to a tar archive:
docker export <container-name> > testcontainer.tar
- Import the tarball as a fresh image:
Docker returns a new image ID, e.g.:docker image import testcontainer.tar newimage:latest
sha256:8909b7da236bb21aa2e52e6e04dff4b7103753e4046e15457a3daf6dfa723a12
- List local images to confirm the import:
Example output:docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE newimage latest 8090b7da236b 2 minutes ago 5.6MB alpine latest a187dde48cd2 4 weeks ago 5.6MB
Docker CLI Reference
Command | Description |
---|---|
docker pull <repo>:<tag> | Download image from Docker Hub or private registry |
docker image save <image> -o <file>.tar | Save one or more images to a tar archive |
docker image load -i <file>.tar | Load image(s) from a tar archive |
docker export <container> | Export container filesystem as a tar archive |
docker image import <file>.tar <name>:<tag> | Create a new image from a container tarball |
docker image ls | List local Docker images |
Links and References
Watch Video
Watch video content