preface
- In real development, projects typically run on
docker
Inside the container, learnArthas
Before, you need to build the container environment - use
docker pull tomcat
Command from thedocker Hub
The image that you pull down, you useopenJdk
, it does not contain usejps
Command, executejava -jar arthas.jar
Start thearthas
, an error is reported indicating that the Java Process could not be found
1. Before building the Tomcat+Jdk environment, download the Tomcat and Jdk installation packages
Download tomcat8.5 Download jdk1.8
2. Create a Dockerfile file and generate an image
- Upload tomcat and JDK to Linux
- Create a Dockerfile file with the following contents
CMD ["/usr/local/apache tomcat - 8.5.31 / bin/catalina. Sh ", "run"]
You can usedocker logs
Logs are displayed.CMD /usr/local/apache-tomcat-8.5.31/bin/startup.sh && tail -F /usr/local/apache-tomcat-8.5.31/logs/catalina.out
Logs will be placed oncatalina.out
In the file, indocker run
You need to configure the log mount function for viewing logsdocker logs
Unable to view logs
MAINTAINER Easysan <[email protected]> # ADD Java and Tomcat to the container JDK -8u212-linux-x64.tar.gz /usr/local ADD apache-tomcat-8.5.31.tar.gz /usr/local RUN yum -y install vim Set WORKDIR to WORKDIR Configure the Java and Tomcat environment variables ENV JAVA_HOME /usr/local/jdk1.8.0_212 ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.31 ENV CATALINA_BASE /usr/local/apache-tomcat-8.5.31 ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin # ENTRYPOINT ["/usr/local/apache-tomcat-9.0.8/bin/startup.sh"] CMD ["/usr/local/apache-tomcat-8.5.31/bin/catalina.sh","run"] # CMD /usr/local/apache-tomcat-8.5.31/bin/startup.sh && tail -f/usr/local/apache tomcat - 8.5.31 / logs/catalina. OutCopy the code
- In the directory
/mydata/tomcat
useDocker build-t arthas-tomcat:v1.1.0.
Create a mirror image
3. Start the container
Docker run - p - 9999-8080 the name arthas_tomcat - v/mydata/tomcat/webapps / : / usr/local/apache tomcat -- 8.5.31 / webapps - v The/etc/localtime: / etc/localtime: arthas ro - d - tomcat: v1.1.0Copy the code
4. Create a simple Spring Boot project and upload the war package/mydata/tomcat/webapps/
Directory, restart the containerdocker restart 9b87fdb14cb2
5. Download and start Arthas,For details, please refer to the official website
- Into the container
docker exec -it 9b87fdb14cb2 /bin/bash
, where the directory is/usr/local
. The new directorymkdir arthas
Enter thecd arthas
The arthas.jar directory where you downloaded arthas.jar - download
curl -O https://arthas.aliyun.com/arthas-boot.jar
And start thejava -jar arthas.jar
- Select the sequence number of the Java process