[Docker] docker image 백업

docker image 백업 복구

docker command : docker save & docker load

  • 백업할 docker image name 를 확인 합니다. 
[root@centos-docker ftp-service]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                      NAMES
b27a0fcf0969        ssh-server          "/usr/sbin/sshd -D"      2 minutes ago       Up 2 minutes        0.0.0.0:22222->22/tcp                                      ssh-server
1a1af135eebc        pure-ftpd           "/bin/sh -c '/usr/sb…"   2 minutes ago       Up 2 minutes        0.0.0.0:21->21/tcp, 0.0.0.0:20000-20099->20000-20099/tcp   ftpd
[root@centos-docker ftp-service]#

 

  • docker save 명령어로 image 를 백업 합니다.
[root@centos-docker ftp-service]# docker save -o ssh-server.tar ssh-server
[root@centos-docker ftp-service]# docker save -o pure-ftpd.tar pure-ftpd

 

  • docker-compose 디렉토리를 백업합니다.
[root@centos-docker ftp-service]# cd ..
anaconda-ks.cfg  ftp-service 
[root@centos-docker ~]# tar cvf ftp-service.tar ftp-service/
ftp-service/
ftp-service/ssh-server/
ftp-service/ssh-server/Dockerfile
ftp-service/docker-compose.yml
ftp-service/pure-ftpd/
ftp-service/pure-ftpd/Dockerfile
ftp-service/pure-ftpd/pureftpd.passwd
ftp-service/ssh-server.tar
ftp-service/pure-ftpd.tar
[root@centos-docker ~]#

 

  • docker image 복구 (scp 나 ftp 를 이용하여 복구할 시스템에서 ftp-service.tar 파일을 복사해옵니다.)
[root@centos74-docker02 ~]# scp root@192.168.1.23:/root/ftp-service.tar .
[root@centos74-docker02 ~]# tar xvf ftp-service.tar
[root@centos74-docker02 ~]# cd ftp-service/

 

  • docker load 명령어를 이용하여 docker image 를 load 합니다.
[root@centos74-docker02 ftp-service]# docker load -i ssh-server.tar
aa54c2bc1229: Loading layer [==================================================>]  121.6MB/121.6MB
7dd604ffa87f: Loading layer [==================================================>]  15.87kB/15.87kB
2f0d1e8214b2: Loading layer [==================================================>]  11.78kB/11.78kB
297fd071ca2f: Loading layer [==================================================>]  3.072kB/3.072kB
4f78d015fcfa: Loading layer [==================================================>]  5.632kB/5.632kB
5b2e491f227c: Loading layer [==================================================>]  104.2MB/104.2MB
0e6f6b46199d: Loading layer [==================================================>]  3.072kB/3.072kB
Loaded image: ssh-server:latest
[root@centos74-docker02 ftp-service]# docker load -i pure-ftpd.tar
eef560b4ec4f: Loading layer [==================================================>]    197MB/197MB
11a0c2f551fd: Loading layer [==================================================>]  209.9kB/209.9kB
dda5ec330bd9: Loading layer [==================================================>]  7.168kB/7.168kB
5f96fa66dc12: Loading layer [==================================================>]  3.072kB/3.072kB
5e158c9ee888: Loading layer [==================================================>]  5.632kB/5.632kB
df1e500aba99: Loading layer [==================================================>]  210.5MB/210.5MB
f97cf7fc54cb: Loading layer [==================================================>]  13.94MB/13.94MB
d622b75b6850: Loading layer [==================================================>]  5.637MB/5.637MB
f1f64220d033: Loading layer [==================================================>]  10.75kB/10.75kB
93a7b057a761: Loading layer [==================================================>]  4.293MB/4.293MB
34e855b6a251: Loading layer [==================================================>]  582.7kB/582.7kB
44de25e21a3f: Loading layer [==================================================>]  379.4kB/379.4kB
62f4467edb00: Loading layer [==================================================>]  3.584kB/3.584kB
3b53068e8e0f: Loading layer [==================================================>]   5.12kB/5.12kB
6a75a4844f83: Loading layer [==================================================>]  3.072kB/3.072kB
Loaded image: pure-ftpd:latest
[root@centos74-docker02 ftp-service]#

 

  • docker image 를 확인 합니다.
  • docker-compose 를 실행 합니다.
[root@centos74-docker02 ftp-service]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ssh-server          latest              286889354875        27 minutes ago      217MB
pure-ftpd           latest              50a17f653588        28 minutes ago      415MB
[root@centos74-docker02 ftp-service]#
[root@centos74-docker02 ftp-service]# docker-compose up -d
Creating ssh-server ... done
Creating ftpd       ... done
[root@centos74-docker02 ftp-service]#

 

  • 서비스 확인을 진행 합니다.

 

댓글 남기기