docker cp 容器id:容器内路径 目的的主机路径
例:
[root@iZ2ze3mgup8rrtkhrsdxxsZ ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1ca135b0a3da centos "/bin/bash" 20 minutes ago Exited (0) About a minute ago fervent_chatelet
f952ffce8706 centos "/bin/bash" 30 minutes ago Exited (0) 30 minutes ago hopeful_liskov
347eab13458b centos "/bin/bash" 30 minutes ago Exited (0) 30 minutes ago trusting_cori
101004d42920 centos "/bin/bash" 33 minutes ago Exited (130) 32 minutes ago nostalgic_yalow
284aaa9018a4 centos "/bin/bash" 2 days ago Exited (0) 2 days ago optimistic_roentgen
4dd6fa58465e centos "/bin/hash" 2 days ago Exited (0) 2 days ago intelligent_cray
[root@iZ2ze3mgup8rrtkhrsdxxsZ ~]# docker cp 1ca135b0a3da:home/test.java /home
[root@iZ2ze3mgup8rrtkhrsdxxsZ ~]# ls
[root@iZ2ze3mgup8rrtkhrsdxxsZ ~]# cd /home
[root@iZ2ze3mgup8rrtkhrsdxxsZ home]# ls
admin test.java
[root@iZ2ze3mgup8rrtkhrsdxxsZ home]#