1.下载jre镜像并推送到harbor
[root@hdss7- ~]# docker pull registry.cn-hangzhou.aliyuncs.com/yfhub/jre8:8u112
[root@hdss7- ~]# docker tag registry.cn-hangzhou.aliyuncs.com/yfhub/jre8:8u112 harbor.fx.com/public/jre8:8u112
docker push harbor.fx.com/public/jre8:8u112
2.自定义Dockerfile文件
[root@hdss7- ~]# mkdir -p /data/dockerfile/jre8
[root@hdss7- ~]# vim /data/dockerfile/jre8/Dockerfile
FROM harbor.fx.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..jar /opt/prom/
WORKDIR /opt/project_dir
ADD entrypoint.sh /entrypoint.sh
CMD ["/entrypoint.sh"]
[root@hdss7- ~]# chmod +x /data/dockerfile/jre8/entrypoint.sh
config.yml文件
[root@hdss7- ~]# vim /data/dockerfile/jre8/config.yml
---
rules:
- pattern: '.*'
entrypoint.sh
[root@hdss7- ~]# vim /data/dockerfile/jre8/entrypoint.sh
#!/bin/sh
M_OPTS="-Duser.timezone=Asia/Shanghai -javaagent:/opt/prom/jmx_javaagent-0.3.1.jar=$(hostname -i):${M_PORT:-""}:/opt/prom/config.yml"
C_OPTS=${C_OPTS}
JAR_BALL=${JAR_BALL}
exec java -jar ${M_OPTS} ${C_OPTS} ${JAR_BALL}
下载jmx_javaagent-0.3.1.jar
[root@hdss7- ~]# wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar -O /data/dockerfile/jre8/jmx_javaagent-0.3.1.jar
3.在harbor里创建一个公有的base(所有底包)仓库
4.构建底包并且上传到harbor
[root@hdss7- jre8]# docker build . -t harbor.fx.com/base/jre8:8u112
[root@hdss7-200 jre8]# docker push harbor.fx.com/base/jre8:8u112