• 实战交付一套dubbo微服务到k8s集群(4)之dubbo微服务底包镜像制作


    1.下载jre镜像

    在运维主机(mfyxw50.mfyxw.com)操作

    [root@mfyxw50 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/yfhub/jre8:8u112
    

    image-20200529140852178

    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
    

    image-20200529151106371

    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
    

    image-20200529153053285

    config.yml文件

    [root@mfyxw50 ~]# cat > /data/dockerfile/jre8/config.yml << EOF
    ---
    rules:
      - pattern: '.*'
    EOF
    

    image-20200529152913405

    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
    

    image-20200529152845672

    下载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
    

    image-20200529152718929

    4.在harbor里创建一个公有的base(所有底包)仓库

    image-20200529160254150

    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
    

    image-20200529160513079

    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
    

    image-20200529161342252

  • 相关阅读:
    利用GitHub和Hexo打造免费的个人博客 coder
    Android基础——项目的文件结构(二) coder
    25个Android酷炫开源UI框架 coder
    MarkDown使用教程(In Atom) coder
    Android基础——项目的文件结构(一) coder
    25类Android常用开源框架 coder
    Android Activity启动黑/白屏原因与解决方式 coder
    我的window phone 开发第一步
    Entity Framework 4 In Action 读书笔记
    最近在制作一套ASP.NET控件,已初见雏形
  • 原文地址:https://www.cnblogs.com/Heroge/p/13097691.html
Copyright © 2020-2023  润新知