Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to customize Tomcat by DockerFile

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how DockerFile customizes Tomcat. The content is concise and easy to understand. It will definitely make your eyes shine. I hope you can gain something through the detailed introduction of this article.

DockerFile Custom Tomcat9

Test the following two reserved word instructions

3.7 ADD copies the files in the host directory into the mirror and ADD automatically processes URL and tar decompression packages ADD centos-7-docker.tar.xz (COPY Copy directly, ADD copy + decompress)3.8 ", COPY similar ADD, copy files and directories to the mirror COPY src desc or COPY["src","desc"]

Case:

1. Create tomcat9 directory mkdir tomcat92, Create the file touch c.txt3, Copy the compressed package of JDK and tomcat installation package into the previous directory apache-tomcat-9.0.8.tar.gz jdk-8u171-linux-x64,tar.gz4. Create a Dockerfile file under tomcat9. Contents of the directory: FROM centos MAINTAINER mytomcat_lee #Copy the host's current context c.txt to the container/usr/local/path COPY c.txt /usr/local/cincontainer.txt #Add java and tomcat to container ADD jdk-8u171-linux-x64,tar.gz ADD apache-tomcat-9.0.8.tar.gz #Install vim editor RUN yum -y install vim #Set workdir path when visiting work, login foothold ENV MYPATH /usr/local WORKDIR $MYPATH #Configure java and tomcat environment variables ENV JAVA_HOME /usr/local/jdk1.8.0_171 ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.8 ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.8 ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin #Interface on which the container listens at runtime EXPOSE 8080 #Start running tomcat #ENTRYPOINT ["/usr/local/apache-tomcat-9.0.8/bin/startup.sh"] #CMD ["/usr/local/apache-tomcat-9.0.8/bin/catalina.sh","run"] CMD /usr/local/apache-tomcat-9.0.8/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.8/bin/logs/catalina.out 5. Build Mirror docker build Dockerfile -t mytomcat9 . (-f 6. Test docker images7. Run docker run -d -p 9080:8080 --name myt9 -v /opt/tomcat9/test:/usr/local/apache-tomcat-9.0.8/webapps/test -v /opt/tomcat9/tomcat9logs/:/usr/local/apache-tomcat-9.0.8/logs --privileged=true mytomcat9 (--privileged=true is added to prevent-v from not having enough write permissions when mounting the container volume) 8. docker ps9. http://localhost:908010. Throw a project under/opt/tomcat9/test to test whether myt9 can run 11. docker restart myt9 Restart the container. The above content is DockerFile. How to customize Tomcat. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report