• dockerfile构建javaweb镜像等系列操作


    # 先构建 tomcat + jdk 的环境镜像, 后续再将war文件放入,在生成新镜像
    
    [root@k8s-master dockerfile]# ls
    apache-tomcat-9.0.30  apache-tomcat-9.0.30.tar.gz  dockerfile  jdk1.8.0_241  jdk-8u241-linux-x64.tar.gz
    
    # dockerfile文件内容
    [root@k8s-master dockerfile]# cat dockerfile

     FROM centos:latest
      MAINTAINER 18260070505@163.com
      COPY ./jdk1.8.0_241 /usr/local/jdk1.8.0_241
      COPY ./apache-tomcat-9.0.30 /usr/local/apache-tomcat-9.0.30

    
    

      ENV JAVA_HOME /usr/local/jdk1.8.0_241
      ENV JRE_HOME $JAVA_HOME/jre
      ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
      ENV PATH $PATH:$JAVA_HOME/bin
      ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.30
      ENV CATALINA_OPTS -Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=512M
      RUN cd $CATALINA_HOME/logs && echo "1" >>count.txt
      ENTRYPOINT $CATALINA_HOME/bin/startup.sh && tail -F $CATALINA_HOME/logs/catalina.out

    # 构建镜像
    [root@k8s-master dockerfile]# docker build -t="wzllzw/tomcat" .
    
    # 环境镜像构建到此完成
    # 将war文件放入容器
    [root@k8s-master dockerfile]# docker cp myapp_1.war tomcat_wzl:/usr/local/apache-tomcat-9.0.30/webapps
    # 将容器生成新的镜像
    [root@k8s-master dockerfile]# docker commit -a "18260070505@163.com" 56c4f6fb99cb wzllzw/myapp:0.0.1
    # 登录阿里云
    [root@k8s-master docker]# docker login --username=XXXXXXXXX  registry.cn-hangzhou.aliyuncs.com
    
    # 改tag
    [root@k8s-master docker]# docker tag 99c616c01fe3 registry.cn-hangzhou.aliyuncs.com/wzllzw/myapp:0.0.1
    
    # 上传
    [root@k8s-master docker]# docker push  registry.cn-hangzhou.aliyuncs.com/wzllzw/myapp:0.0.1
    The push refers to repository [registry.cn-hangzhou.aliyuncs.com/wzllzw/myapp]
    a2270c4590e5: Pushed 
    7c39ce617225: Pushed 
    b3df98f10832: Pushed 
    ea51a39d2383: Pushed 
    0683de282177: Pushed 
    0.0.1: digest: sha256:5ab72699e80cf838c26b93e01fb4fb572ac5a35b797dd0fad1dc3493954da165 size: 1370

    相关链接:

    1. docker commit 容器生成镜像 :https://www.runoob.com/docker/docker-commit-command.html

    2. 登录阿里云hub :https://www.jianshu.com/p/f15cc2ebcc65

    3. tomcat应用改主页 :https://www.iteye.com/blog/xxs673076773-1134805

    参考资料:

    1. 通过Dockerfilefile构建镜像并发布web项目 :https://www.cnblogs.com/xiaochangwei/p/8204992.html

  • 相关阅读:
    路由相关题目解析
    Centos7.6系统安装
    组播(二)---IGMP
    那些瞬间击中我的句子
    组播(一)
    记一次安装浪潮服务器的经历
    HP打印机驱动安装方法总结
    潍坊矿场ubuntu18 server 基本环境配置常用操作
    docker-zabbix
    MySQL 8.x 账号管理
  • 原文地址:https://www.cnblogs.com/wzllzw/p/12679120.html
Copyright © 2020-2023  润新知