å¦ä½ä½¿ç¨Docker è¿è¡Java å¼å
1ãjava项ç®å¼åï¼åå®å·²æä¸ä¸ªjava项ç®è½å¤ç¼è¯æjar/war并ä¸è¿è¡äºã2ãç¼ådockerfileï¼dockeræ¯ä¸ä¸ªå®¹å¨ææ¯æ¯ä¸ä¸ªå®¹å¨å°±æ¯ä¸ä¸ªâå®æ´âçlinuxç³»ç»ï¼è¿ä¸ªdockerfileéè¦æä¾è¿ä¸ªç³»ç»å å«å 容çæè¿°ï¼æ¯å¦FROM maven:3.3.3ãFROM ubuntu:.ãå¦æè¿ä¸ªjava项ç®æ¯ä¸ªweb项ç®é£ä¹è¿éè¦æä¾tomcatç¯å¢ãæ·»å 项ç®æ建信æ¯ãæ¯å¦éç¨mavenç¼è¯é¡¹ç®çè¯è¯¥å¦ä½å¦ä½ã
ADD pom.xml /tmp/build/RUN cd /tmp/build && mvn -q dependency:resolve
ADD src /tmp/build/src
#æ建åºç¨RUN cd /tmp/build && mvn -q -DskipTests=true package \
#æ·è´ç¼è¯ç»æå°æå®ç®å½
&& rm -rf $CATALINA_HOME/webapps/* \
&& mv target/*.war $CATALINA_HOME/webapps/ROOT.war \
#æ¸ çç¼è¯ç迹
&& cd / && rm -rf /tmp/build
3ãæ´æ¼æ¥å£ï¼EXPOSE
CMD ["catalina.sh",顶源码usbmon+源码"run"]
4ãæ§è¡éåæ建
docker build -t docker-demo-java-tomcat .5ãåºäºå建好çéåå建容å¨
docker run -d -p : docker-demo-java-tomcat6ã访é®
http://.0.0.1:/demoæ¥æºäºdockercloudææ¡£ï¼å¯èªå»æ¥çã
2024-12-24 00:18
2024-12-24 00:12
2024-12-23 23:55
2024-12-23 23:53
2024-12-23 23:50