using docker(# file copy container-host)
docker container의 데이터들을 copy 해보기
1. 환경준비
centos 7.6
docker
2. docker container list
[root@kylin ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
546c2d4a41fb hadoop1 "/bin/bash" 45 hours ago Up 45 hours hello2
a9bb5aa82130 hadoop1 "/bin/bash" 2 days ago Up 2 days hello
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
546c2d4a41fb hadoop1 "/bin/bash" 45 hours ago Up 45 hours hello2
a9bb5aa82130 hadoop1 "/bin/bash" 2 days ago Up 2 days hello
3.hello container 에서 localhost로 파일 복사
[root@kylin ~]# docker cp hello:/root/.ssh/authorized_keys ./
[root@kylin ~]# ls
anaconda-ks.cfg authorized_keys hadoopct.tar initial-setup-ks.cfg
[root@kylin ~]#
4.localhost에서 hello container 로 파일 복사
[root@kylin ~]# docker cp ./authorized_keys hello2:/root/.ssh/
[root@kylin ~]# docker exec -it hello2 bash
[root@546c2d4a41fb /]# ls
anaconda-post.log dev hadoop-3.1.2 home lib64 mnt proc run srv tmp var
bin etc hadoop-3.1.2.tar.gz lib media opt root sbin sys usr
[root@546c2d4a41fb /]# ls /root/.ssh
authorized_keys id_rsa id_rsa.pub known_hosts
[root@546c2d4a41fb /]# ls -al /root/.ssh
total 16
drwx------. 1 root root 29 Aug 7 02:01 .
dr-xr-x---. 1 root root 18 Aug 4 01:38 ..
-rw-------. 1 root root 399 Aug 4 01:39 authorized_keys
-rw-------. 1 root root 1679 Aug 4 01:38 id_rsa
-rw-r--r--. 1 root root 399 Aug 4 01:38 id_rsa.pub
-rw-r--r--. 1 root root 521 Aug 4 01:40 known_hosts
[root@546c2d4a41fb /]#
댓글
댓글 쓰기