• 使用Dockerfile制作JDK+tomcat镜像


    1、准备好jdk和tomcat
    apache-tomcat-8.5.63.tar.gz
    jdk-8u162-linux-x64.tar.gz

    注意:
    a、jdk和tomcat记得从官网下载,否则制作出来的镜像容易出现不兼容问题。
    b、apache-tomcat-8.5.63.tar.gz、jdk-8u162-linux-x64.tar.gz、Dockerfile放在同一目录

    2、编写Dockerfile,内容如下:

    [root@muze1 local]# cat Dockerfile
    FROM centos:latest
    MAINTAINER jox
    # now add java and tomcat support in the container
    ADD jdk-8u162-linux-x64.tar.gz        /usr/local/
    ADD apache-tomcat-8.5.63.tar.gz    /usr/local/

    # configuration of java and tomcat ENV
    ENV JAVA_HOME /usr/local/jdk1.8.0_162
    ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.63
    ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin

    # container listener port
    EXPOSE 8080
    # startup web application services by self
    CMD /usr/local/apache-tomcat-8.5.63/bin/catalina.sh run

    文件目录结果如下:

     3、设置Dockerfile权限

    chmod 777 Dockerfile

    4、开始制作镜像

    [root@muze1 local]# docker build -t tomcat8.5.63:v1 /usr/local/
    Sending build context to Docker daemon 3.919GB
    Step 1/10 : FROM centos:latest
    ---> 300e315adb2f
    Step 2/10 : MAINTAINER john
    ---> Running in 992c98201308
    Removing intermediate container 992c98201308
    ---> e10ad819da34
    Step 3/10 : ADD jdk-8u162-linux-x64.tar.gz /usr/local/
    ---> c32ae07e4431
    Step 4/10 : ADD apache-tomcat-8.5.63.tar.gz /usr/local/
    ---> 33c491e0717e
    Step 5/10 : ENV JAVA_HOME /usr/local/jdk1.8.0_162
    ---> Running in 873b128cc856
    Removing intermediate container 873b128cc856
    ---> 97cb31c7501b
    Step 6/10 : ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    ---> Running in 07208570bfe3
    Removing intermediate container 07208570bfe3
    ---> 7454a5fcd55c
    Step 7/10 : ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.63
    ---> Running in ad5edb6cd83a
    Removing intermediate container ad5edb6cd83a
    ---> 9be57e5b393e
    Step 8/10 : ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
    ---> Running in ff7c857cb95a
    Removing intermediate container ff7c857cb95a
    ---> 4476caec203a
    Step 9/10 : EXPOSE 8080
    ---> Running in 440323f39093
    Removing intermediate container 440323f39093
    ---> f0b0a0021aaa
    Step 10/10 : CMD /usr/local/apache-tomcat-8.5.63/bin/catalina.sh run
    ---> Running in a36f0bcba6d8
    Removing intermediate container a36f0bcba6d8
    ---> 11580452a093
    Successfully built 11580452a093
    Successfully tagged tomcat8.5.63:v1

    5、检查当前镜像

    [root@muze1 local]# docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    tomcat8.5.63 v1 11580452a093 35 seconds ago 609MB
    nginx latest d1a364dc548d 9 days ago 133MB
    tomcat latest c43a65faae57 3 weeks ago 667MB
    mysql latest c0cdc95609f1 3 weeks ago 556MB
    lhrbest/lhrcentos76 8.2 14ab81d0ca62 8 weeks ago 3.41GB
    centos latest 300e315adb2f 5 months ago 209MB
    iwanttobefreak/weblogic1036 latest a54169dcf667 4 years ago 783MB
    jaspeen/oracle-11g latest 0c8711fe4f0f 5 years ago 281MB
    ismaleiva90/weblogic12 latest 84795663769d 5 years ago 3.65GB

    6、使用制作的镜像运行容器

    [root@muze1 local]# docker run -d -p 28080:8080 --name tomcat8_test tomcat8.5.63:v1
    43d94b4bc89b2359b6f7d8c082ad351b0ea25c2c1ec6792e3c37e251c03d12e3
    [root@muze1 local]# docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    43d94b4bc89b tomcat8.5.63:v1 "/bin/sh -c '/usr/lo…" 3 seconds ago Up 3 seconds 0.0.0.0:28080->8080/tcp tomcat8_test
    fd453e0604ba mysql "docker-entrypoint.s…" 17 hours ago Up 17 hours 33060/tcp, 0.0.0.0:13306->3306/tcp zxk-mysql
    3a0ab1009b22 nginx "/docker-entrypoint.…" 9 days ago Up 8 days 0.0.0.0:81->80/tcp hopeful_cerf

    7、验证容器里的tomcat服务

     

  • 相关阅读:
    利用performSelectorInBackground和performSelectorOnMainThread实现多线程刷新UI
    iOS之NSCocoaErrorDomain Code=3840
    iOS之原生地图与高德地图
    iOS之Storyboard References
    iOS之内购
    iOS之上线被拒
    iOS之可拖拽重排的CollectionView
    iOS之内购
    ios专题
    ios专题
  • 原文地址:https://www.cnblogs.com/vzhangxk/p/14848886.html
Copyright © 2020-2023  润新知