[docker] Container Backup and Recovery

Container Backup and Recovery

컨테이너를 tar 파일로 저장

 

Container Backup

docker-test01 Server 에서 ssh-server.tar 파일 생성

test@docker-test01:~$ docker ps
CONTAINER ID        IMAGE               COMMAND               CREATED             STATUS              PORTS                   NAMES
4a9c504e3fc0        ssh-server          "/usr/sbin/sshd -D"   8 minutes ago       Up About a minute   0.0.0.0:12341->22/tcp   ssh-server
test@docker-test01:~$

docker commit 
test@docker-test01:~$ docker commit -p 4a9c504e3fc0 ssh-server
sha256:7497e5839808a3d16aa4e665250b0b56c2c2b68316389583a8dc5b3a369a0e1d
test@docker-test01:~$

docker save
test@docker-test01:~$ docker save -o ssh-server.tar ssh-server

 

Container Recovery

docker-test02 Server 에서 docker load 명령어를 이용하여 ssh-server.tar 파일을 load

test@docker-test02:~/ssh-server$ docker load -i ssh-server.tar
ff986b10a018: Loading layer  115.7MB/115.7MB
9c7183e0ea88: Loading layer  15.87kB/15.87kB
c98ef191df4b: Loading layer  14.85kB/14.85kB
92914665e7f6: Loading layer  5.632kB/5.632kB
6f4ce6b88849: Loading layer  3.072kB/3.072kB
45c63a717468: Loading layer  98.94MB/98.94MB
6a99d630753a: Loading layer  3.072kB/3.072kB
4974e070de92: Loading layer  302.1kB/302.1kB
Loaded image: ssh-server:latest
test@docker-test02:~/ssh-server$
image 확인
test@docker-test02:~/ssh-server$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ssh-server          latest              7497e5839808        11 minutes ago      207MB
test@docker-test02:~/ssh-server$

 

ssh-server 실행

test@docker-test02:~/ssh-server$ mkdir ~/ftp
test@docker-test02:~/ssh-server$ docker run --name ssh-server -d -p 12341:22 -v /home/test/ftp:/home/test/ftp ssh-server
210ec4045be4be565689aebcb00d5d7171f954efdb1bf493563a7669a74b7400
test@docker-test02:~/ssh-server$ docker ps
CONTAINER ID        IMAGE               COMMAND               CREATED             STATUS              PORTS                   NAMES
210ec4045be4        ssh-server          "/usr/sbin/sshd -D"   3 seconds ago       Up 2 seconds        0.0.0.0:12341->22/tcp   ssh-server
test@docker-test02:~/ssh-server$

 

 

댓글 남기기