maven 官方地址: 官方地址
下载maven,shdd7-200
# cd /opt/src
# wget https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
# mkdir /data/nfs-volume/jenkins_home/maven-3.6.1-8u232
# tar -zxf apache-maven-3.6.1-bin.tar.gz -C /data/nfs-volume/jenkins_home/maven-3.6.1-8u232/
# cd /data/nfs-volume/jenkins_home/maven-3.6.1-8u232
# mv apache-maven-3.6.1/* ./
# rm -rf apache-maven-3.6.1/
初始化maven配置:
# vi /data/nfs-volume/jenkins_home/maven-3.6.1-8u232/conf/settings.xml
<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
制作dubbo微服务底包镜像:JAVA运行时环境的底包
# docker push stanleyws/jre8:8u112
# docker tag fa3a085d6ef1 harbor.od.com/public/jre:8u112
# docker push harbor.od.com/public/jre:8u112
创建Dockerfile:
# cd /data/dockerfile/ # mkdir jre8 # cd jre8 # vi Dockerfile
FROM harbor.od.com/public/jre:8u112 RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo ‘Asia/Shanghai‘ >/etc/timezone ADD config.yml /opt/prom/config.yml ADD jmx_javaagent-0.3.1.jar /opt/prom/ WORKDIR /opt/project_dir ADD entrypoint.sh /entrypoint.sh CMD ["/entrypoint.sh"]
创建Dockerfile所需文件:
# vi config.yml
--- rules: - pattern: ‘.*‘
下载jmx_javaagent,监控jvm信息:
# wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar -O jmx_javaagent-0.3.1.jar
创建entrypoint.sh:使用exec 来运行java的jar包,能够使脚本将自己的pid 为‘1’ 传递给java进程,避免docker容器因没有前台进程而退出。并且不要加&符。
# vi entrypoint.sh
#!/bin/sh M_OPTS="-Duser.timezone=Asia/Shanghai -javaagent:/opt/prom/jmx_javaagent-0.3.1.jar=$(hostname -i):${M_PORT:-"12346"}:/opt/prom/config.yml" C_OPTS=${C_OPTS} JAR_BALL=${JAR_BALL} exec java -jar ${M_OPTS} ${C_OPTS} ${JAR_BALL}
执行权限:
# chmod u+x entrypoint.sh
执行docker build:base仓库自行创建,权限公开
# docker build . -t harbor.od.com/base/jre8:8u112
原文地址:https://www.cnblogs.com/slim-liu/p/11978435.html
时间: 2024-10-05 00:25:10