1. OverviewThe previous article introduced how to deploy spring boot using docker and connect to skywalking, which described how to build skywalking using docker-compose. This article will not introduce how to build skywalking. Here we will mainly record how to deploy a tomcat using docker and connect to skywalking for service link tracking. 2. Use docker to deploy tomcat and connect to skywalkingThe following is a description of how to connect the tomcat application to the skywalking official website:
Linux Tomcat 7 / Tomcat 8 CATALINA_OPTS="$CATALINA_OPTS -javaagent:<skywalking-agent-path>"; export CATALINA_OPTS Windows Tomcat 7 / Tomcat 8 set "CATALINA_OPTS=-javaagent:<skywalking-agent-path>" JAR File or Spring Boot java -javaagent:<skywalking-agent-path> -jar yourApp.jar
Since I am using docker to deploy tomcat, I don't plan to modify the In the figure below, a script that reads This means: do not set variables in the 1. Write custom variables in the setenv.sh file First, we need to download the skywalking agent. For information about downloading the agent, you can refer to the article at the beginning of this article. Then put the agent in an accessible directory. I am testing here, so I copied the agent directory to the same directory as my Dockerfile. The content of FROM tomcat LABEL maintaner="xiniao" COPY agent /usr/skywalking/agent WORKDIR /usr/local/tomcat/bin RUN echo 'CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/skywalking/agent/skywalking-agent.jar";' > setenv.sh ENV SW_AGENT_NAME="my-spring-demo" \ SW_AGENT_COLLECTOR_BACKEND_SERVICES="127.0.0.1:11800" WORKDIR /usr/local/tomcat/webapps/ROOT COPY target/my-spring-demo.war my-spring-demo.war RUN jar -xf my-spring-demo.war As for other configurations of skywalking agent, they can be defined by environment variables. For example, here we specify the service name displayed in skywalking as 2. Use environment variables to specify the path of skywalking agent The detailed FROM tomcat LABEL maintaner="xiniao" COPY agent /usr/skywalking/agent ENV CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/skywalking/agent/skywalking-agent.jar" \ SW_AGENT_NAME="my-spring-demo-env" \ SW_AGENT_COLLECTOR_BACKEND_SERVICES="127.0.0.1:11800" WORKDIR /usr/local/tomcat/webapps/ROOT COPY target/my-spring-demo.war my-spring-demo.war RUN jar -xf my-spring-demo.war Use the following command to build the image: docker build -t my-spring-demo . Run the container using the following command: docker run --rm -p 8080:8080 my-spring-demo Visit the skywalking ui and you can see the monitoring information as follows: SummarizeThis article mainly introduces how to use docker to deploy tomact and connect it to skywalking. Since there is not much relevant information on the Internet, I record it here to provide some help to those who need it. There are still some problems here. For example, it is not friendly to directly type the skywalking agent into the image file. I think you can customize a tomcat base image and type the skywalking agent into the base image. In this way, all tomcats can reference this base image to build images and connect to skywalking. If you use k8s for deployment, you can define an initial container in the pod. When the pod starts, copy the skywalking agent in the initial container to our application. I will introduce how to use skywalking in k8s and connect the pod application to skywalking without intrusion in the next article. This is the end of this article about using docker to deploy tomcat and connect to skywalking. For more relevant content about docker to deploy tomcat and connect to skywalking, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
The steps are as follows 1. Create a docker group...
HTML imitates the Baidu Encyclopedia navigation d...
1. Download mysql-8.0.17-winx64 from the official...
The solution to the problem that mysql cannot be ...
The SQL query statement execution order is as fol...
Linux online installation related commands: yum i...
Similar to the code hosting service provided by G...
There is no mysql by default in the yum source of...
String functions Check the ascii code value of th...
This article mainly introduces how to integrate T...
Since I have parsed HTML before, I want to use Vu...
Installation environment: CAT /etc/os-release Vie...
Only show the top border <table frame=above>...
Table of contents Preface Child components pass d...
This article example shares the specific code for...