[root@localhost software]# docker run -it -d -p 9995:8080 -v /usr/local/software/tomcat_p_9995/:/usr/local/tomcat/webapps --privileged=true tomcat:8.5 1f53c5b786b9a57843e5fa714afb7d7b8151614b5c2f602029c14d1a229a417a [root@localhost software]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1f53c5b786b9 tomcat:8.5 "catalina.sh run" About a minute ago Up About a minute 0.0.0.0:9995->8080/tcp hardcore_volhard [root@localhost software]# docker exec -it 1f53c5b786b9 /bin/bash root@1f53c5b786b9:/usr/local/tomcat/webapps# ls root@1f53c5b786b9:/usr/local/tomcat# exit exit
容器里的webapps是空的
把webapps复制到宿主机的数据卷中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[root@localhost download]# ls apache-tomcat-8.5.58 apache-tomcat-8.5.58.tar.gz [root@localhost download]# cd apache-tomcat-8.5.58 [root@localhost apache-tomcat-8.5.58]# ls bin conf lib logs README.md RUNNING.txt webapps BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work [root@localhost apache-tomcat-8.5.58]# cp -r webapps/* /usr/local/software/tomcat_p_9995/ [root@localhost tomcat_p_9995]# ls docs examples host-manager manager ROOT [root@localhost tomcat_p_9995]# docker exec -it 1f53c5b786b9 /bin/bash root@1f53c5b786b9:/usr/local/tomcat# ls BUILDING.txt LICENSE README.md RUNNING.txt conf logs temp webapps.dist CONTRIBUTING.md NOTICE RELEASE-NOTES bin lib native-jni-lib webapps work root@1f53c5b786b9:/usr/local/tomcat# cd webapps root@1f53c5b786b9:/usr/local/tomcat/webapps# ls ROOT docs examples host-manager manager