• Docker-Dockerfile方式创建镜像


    Dockerfile

    FROM centos
    MAINTAINER bingjjfly<bingjjfly@docker.org>
    
    ADD /mydocker/tomcat/jdk-8u161-linux-x64.tar.gz /usr/local/
    ADD /mydocker/tomcat/apache-tomcat-8.5.54.tar.gz /usr/local/
    
    RUN	yum install -y vim
    RUN	yum install -y net-tools
    
    ENV WORK_DIR /usr/local/
    WORKDIR $WORK_DIR
    
    ENV JAVA_HOME /usr/local/jdk1.8.0_161
    ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.54
    ENV CATALINA_BASE /usr/local/apache-tomcat-8.5.54
    ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
    
    EXPOSE 8080
    CMD $CATALINA_HOME/bin/startup.sh && tail -F $CATALINA_HOME/logs/catalina.out
    

    Build

    docker build -f /mydocker/tomcat/Dockerfile -t bingjjfly/tomcat:1.0 .
    

    Run

    docker run -d -p 8080:8080 --name bingjjfly_tomcat_1.0 
    	-v /mydocker/tomcat/test:/usr/local/apache-tomcat-8.5.54/webapps/test 
    	-v /mydocker/tomcat/test_logs:/usr/local/apache-tomcat-8.5.54/logs 
    	bingjjfly/tomcat:1.0
    

    Test项目

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    						   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    	   version="2.5">
    <display-name>test</display-name>
    </web-app>
    
    <%@ page contentType="text/html;charset=UTF-8" %>
    <html>
        <body>
    	Hello Dockerfile!
               <%
                      out.println("Hello World!");
               %>
        </body>
    </html>
    

    覆盖CMD命令,不运行容器

    docker run bingjjfly/tomcat:1.0 ls -l
    

    不使用交互,直接执行命令  

    docker exec -it  bingjjfly_tomcat_1.0 ls -l /usr/local/apache-tomcat-8.5.54/webapps/test
    

      

  • 相关阅读:
    聊聊 Java8 以后各个版本的新特性
    如何使用SpringBoot封装自己的Starter
    Git原理入门解析
    Linux磁盘管理:LVM逻辑卷的拉伸及缩减
    LVM在线扩容
    Ubuntu setup Static IP Address
    ubuntu修改主机名
    user.sh
    升级Dell的R810固件版本
    DSET收集ESXi硬件日志
  • 原文地址:https://www.cnblogs.com/BINGJJFLY/p/12808549.html
Copyright © 2020-2023  润新知