Import & Export Docker Image

· 2 min read
Import & Export Docker Image

This post is more like a note to myself, but this may help if you are looking at How to Import & Export Docker Image.

Save / Export Docker Image

  1. Without Compression
# docker save image_name/id_image:tag > output_name
docker save nginx:latest > nginx.tar

2. With Compression

# docker save image_name/id_image:tag | gzip > output_name
docker save nginx:latest | gzip > nginx.tar.gz

Comparison of uncompressed nginx container images with gzip compression

rjhaikal:~# ls -lh nginx.tar nginx.tar.gz
-rw-r--r-- 1 ada ada 132M Feb 24 08:16 nginx.tar
-rw-r--r-- 1 ada ada  50M Feb 24 08:16 nginx.tar.gz

Load / Import Docker Image

# docker load < file_name
docker load < nginx.tar

Reference

docker save
docker save: Produces a tarred repository to the standard output stream. Contains all parent layers, and all tags + versions, or specified `repo:tag`, for each argument provided.
docker load
docker load: Load an image or repository from a tar archive (even if compressed with gzip, bzip2, or xz) from a file or STDIN. It restores both images and tags....