0、目录结构
1、Dockerfile
FROM jre:8u211
COPY apm /apm
COPY run.sh *.jar /usr/local/
EXPOSE 19080
CMD ["/usr/local/run.sh"]
2、构建指令
sudo docker build -t simple-apm-agent-test:0.0.1 .
sudo docker images | grep "apm/simple-apm-agent-test"
3、运行指令
sudo docker run -d -p 19080:19080 --name simple-apm-agent-test simple-apm-agent-test:0.0.1
4、执行指令
程序内:
#!/bin/bash
cd /usr/local
export JAVA_HOME=/usr/local/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
AGENT_URL="-javaagent:/apm/pinpoint-bootstrap-v2.0.3.jar -Dpinpoint.agentId=你的id -Dpinpoint.applicationName=你的应用名"
AGENT_PARAMS="-Dprofiler.collector.ip=你的ip -Dprofiler.collector.span.port=端口udp1 -Dprofiler.collector.stat.port=端口udp2 -Dprofiler.collector.tcp.port=端口tcp -Dprofiler.entrypoint=扫描包路径"
nohup java -jar -Dspring.profiles.active=docker ${AGENT_URL} ${AGENT_PARAMS} -Xms2048m -Xmx2048m simple-apm-agent-test-0.0.1-SNAPSHOT.jar >> simple-apm-agent-test.out 2>&1 &
tail -f simple-apm-agent-test.out
进入虚拟机
sudo docker ps | grep simple
sudo docker exec -it 容器id /bin/bash
or
sudo docker exec -it $(sudo docker ps -a|grep simple-apm-agent-test |awk '{print $1}') /bin/bash
5、删除指令
删除进程
sudo docker rm $(sudo docker ps -a|grep simple-apm-agent-test |awk '{print $1}') -f
删除镜像
sudo docker rmi $(sudo docker images | grep simple-apm-agent-test |awk '{print $3}')