1.下载jre镜像
在运维主机(mfyxw50.mfyxw.com)操作
[root@mfyxw50 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/yfhub/jre8:8u112
2.把jre上传至私有仓库
在运维主机(mfyxw50.mfyxw.com)上操作
[root@mfyxw50 ~]# docker images | grep jre
[root@mfyxw50 ~]# docker tag registry.cn-hangzhou.aliyuncs.com/yfhub/jre8:8u112 harbor.od.com/public/jre8:8u112
[root@mfyxw50 ~]# docker login harbor.od.com
[root@mfyxw50 ~]# docker push harbor.od.com/public/jre8:8u112
3.自定义Dockerfile文件
在运维主机(mfyxw50.mfyxw.com)上操作
[root@mfyxw50 ~]# mkdir -p /data/dockerfile/jre8
[root@mfyxw50 ~]# cat > /data/dockerfile/jre8/Dockerfile << EOF
FROM harbor.od.com/public/jre8: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"]
EOF
[root@mfyxw50 ~]# chmod +x /data/dockerfile/jre8/entrypoint.sh
config.yml文件
[root@mfyxw50 ~]# cat > /data/dockerfile/jre8/config.yml << EOF
---
rules:
- pattern: '.*'
EOF
entrypointsh文件
[root@mfyxw50 ~]# cat > /data/dockerfile/jre8/entrypoint.sh << EOF
#!/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}
EOF
下载jmx_javaagent-0.3.1.jar文件
[root@mfyxw50 ~]# 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
4.在harbor里创建一个公有的base(所有底包)仓库
5.build底包并打标签
在运维主机(mfyxw50.mfyxw.com)上操作
[root@mfyxw50 ~]# cd /data/dockerfile/jre8/
[root@mfyxw50 jre8]# ls
config.yml Dockerfile entrypoint.sh jmx_javaagent-0.3.1.jar
[root@mfyxw50 jre8]# docker build . -t harbor.od.com/base/jre8:8u112
6.把build出来的jre8底包上传到私有仓库
在运维主机(mfyxw50.mfyxw.com)上操作
[root@mfyxw50 ~]# docker images | grep jre
harbor.od.com/base/jre8 8u112 d7286d4ba78d 8 minutes ago 363MB
harbor.od.com/public/jre8 8u112 fa3a085d6ef1 3 years ago 363MB
registry.cn-hangzhou.aliyuncs.com/yfhub/jre8 8u112 fa3a085d6ef1 3 years ago 363MB
[root@mfyxw50 ~]#
[root@mfyxw50 ~]# docker login harbor.od.com
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@mfyxw50 ~]#
[root@mfyxw50 ~]# docker push harbor.od.com/base/jre8:8u112