[Docker](EN) How to save or load Docker image file

Save and Load docker image files.


Environment and Prerequisite

  • Linux base system
  • Bash shell(/bin/bash)
  • Docker


Save docker image to file

docker save

Basic Form

docker save [OPTIONS] IMAGE(by tag) [IMAGE...]

Options

  • --output , -o : Specify output file name.

Examples

  • docker images list
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               stable              ac44715da54a        3 weeks ago         109MB
centos              centos7.5.1804      cf49811e3cdb        3 months ago        200MB
  • centos image example by using redirection
$ sudo docker save centos:centos7.5.1804 > centos-centos7.5.1804-image.tar
$ ls -al centos-centos7.5.1804-image.tar
-rw-rw-r-- 1 twpower twpower 207841280 Jul  4 22:55 centos-centos7.5.1804-image.tar
  • nginx image example by using -o option
$ sudo docker save nginx:stable -o nginx-stable-image.tar
$ ls -al nginx-stable-image.tar
-rw------- 1 root root 113060352 Jul  4 22:56 nginx-stable-image.tar


Load docker image from file

docker load

Basic Form

docker load [OPTIONS]

Options

  • --input , -i : Specify image file name that will be loaded.

Examples

  • centos image example by using redirection
$ ls -al centos-centos7.5.1804-image.tar
-rw-rw-r-- 1 twpower twpower 207841280 Jul  4 22:55 centos-centos7.5.1804-image.tar
$ sudo docker load < centos-centos7.5.1804-image.tar
4826cdadf1ef: Loading layer  207.8MB/207.8MB
Loaded image: centos:centos7.5.1804
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              centos7.5.1804      cf49811e3cdb        3 months ago        200MB
  • nginx image example by using -i option
$ ls -al nginx-stable-image.tar
-rw------- 1 root root 113060352 Jul  4 22:56 nginx-stable-image.tar
$ sudo docker load -i nginx-stable-image.tar
da9fed87e1d3: Loading layer  54.59MB/54.59MB
0d1174230cc6: Loading layer  3.584kB/3.584kB
Loaded image: nginx:stable
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               stable              ac44715da54a        3 weeks ago         109MB
centos              centos7.5.1804      cf49811e3cdb        3 months ago        200MB


Reference

[Docker] 도커(Docker) 이미지 이름과 태그 목록 가져오기

> 도커(Docker) 이미지 이름과 태그 목록을 awk과 tail 명령어를 이용해 가져오는 방법을 알아보자## 환경- Linux 기반 시스템- Bash shell(/bin/bash)- Docker- awk, tail 명령어## 도커(Docker...… Continue reading