1.看下镜像有那些,看到有一个tomcat的镜像
~ docker images REPOSITORY TAG IMAGE ID CREATED SIZE tomcat latest a7fa4ac97be4 6 days ago 528MB mongo latest bcef5fd2979d 4 weeks ago 386MB rabbitmq management db695e07d0d7 3 months ago 181MB memcached latest 0860688a721c 4 months ago 82.2MB nginx 1.17.5 540a289bab6c 5 months ago 126MB redis latest de25a81a5a0b 5 months ago 98.2MB nginx latest f949e7d76d63 6 months ago 126MB redis 5.0.5 63130206b0fa 6 months ago 98.2MB mysql 8.0 b8fd9553f1f0 6 months ago 445MB memcached 1.5.16 c809d7def06c 7 months ago 82.1MB rabbitmq 3.7.7-management 2888deb59dfc 18 months ago 149MB jenkins latest cd14cecfdb3a 20 months ago 696MB
2.直接run 不需要dockerfile文件,只要-v 把宿主机中的tomcat目录挂到docker容器中就可以了,以后直接替换宿主机中的文件再重启就ok了。
打包后的文件命名为ROOT.war,然后创建一个webapps文件夹把ROOT.war方进去就ok了。把webapps目录挂进去就好
docker run --privileged=true --name=promotion-9305 -v /mnt/tomcat/promotion/webapps:/usr/local/tomcat/webapps -d -p 9305:8080 tomcat
3.部署jar项目
#java -jar /mnt/cook-0.0.1-SNAPSHOT.jar这里的路径是容器里面的jar路径
docker run --privileged=true --name xiangchu-service-8085 -d -p 8085:8080 -v /mnt/project-test/xiangchu/cook-interface-service/target/cook-0.0.1-SNAPSHOT.jar:/mnt/cook-0.0.1-SNAPSHOT.jar docker.io/java java -jar /mnt/cook-0.0.1-SNAPSHOT.jar