zoukankan      html  css  js  c++  java
  • ADD/COPY案例

    ADD/COPY案例--自定义镜像tomcat9

    1.mkdir -p /root/mydocker/tomcat9
    2.touch 1.txt
    3.将jdk和tomcat安装包拷贝到目录下

    4.创建Dockerfile文件
    FROM centos
    MAINTAINER yz<yz@126.com>
    #宿主机的1.txt文件拷贝到容器/usr/local下
    COPY 1.txt /usr/local/cincontainer.txt
    #jdk/tomcat
    ADD jdk-8u261-linux-x64.tar.gz /usr/local/
    ADD apache-tomcat-8.5.55.tar.gz /usr/local/
    #INSTALL vim
    RUN yum install -y vim
    #设置WORKDIR
    ENV MYDIR /usr/local
    WORKDIR $MYDIR
    #PATH
    ENV JAVA_HOME /usr/local/jdk1.8.0_261
    ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.55
    ENV CATALINA_BASE /usr/local/apache-tomcat-8.5.55
    ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
    #port
    EXPOSE 8080
    #running tamcat
    CMD /usr/local/apache-tomcat-8.5.55/bin/startup.sh && tail -F /usr/local/apache-tomcat-8.5.55/bin/logs/catalina.out
    
    5.构建镜像
    docker build -f Dockerfile -t mytomcat9 .
    
    6.运行容器
    docker run -d -p 9090:8080 --name mytomcat9 -v /root/mydocker/tomcat9/test:/usr/local/apache-tomcat-8.5.55/webapps/test -v /root/mydocker/tomcat9/logs:/usr/local/apache-tomcat-8.5.55/logs --privileged=true mytomcat9
    
    7.验证
    [root@aaa ~/mydocker/tomcat9]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    a4374713acb0        mytomcat9           "/bin/sh -c '/usr/..."   3 seconds ago       Up 1 second         0.0.0.0:9090->8080/tcp   mytomcat9
    [root@aaa ~/mydocker/tomcat9]# docker exec a4374713acb0 ls -l
    total 0
    drwxr-xr-x 1 root  root   45 Aug  7 03:40 apache-tomcat-8.5.55
    drwxr-xr-x 2 root  root    6 Apr 11  2018 bin
    -rw-r--r-- 1 root  root    0 Aug  7 00:42 cincontainer.txt
    drwxr-xr-x 2 root  root    6 Apr 11  2018 etc
    drwxr-xr-x 2 root  root    6 Apr 11  2018 games
    drwxr-xr-x 2 root  root    6 Apr 11  2018 include
    drwxr-xr-x 8 10143 10143 273 Jun 18 06:59 jdk1.8.0_261
    drwxr-xr-x 2 root  root    6 Apr 11  2018 lib
    drwxr-xr-x 2 root  root    6 Apr 11  2018 lib64
    drwxr-xr-x 2 root  root    6 Apr 11  2018 libexec
    drwxr-xr-x 2 root  root    6 Apr 11  2018 sbin
    drwxr-xr-x 5 root  root   49 May  4 15:35 share
    drwxr-xr-x 2 root  root    6 Apr 11  2018 src
    

    作者:ccku
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。如有问题或建议,请多多赐教,非常感谢。
  • 相关阅读:
    基于WebGIS的电子政务应用(基于J2EE的MVC架构)
    和菜鸟一起学c之函数中堆栈及运行内存情况
    《父亲》献给程序员的我们
    黑客高级技巧之Linux后门技术及实践
    批处理实现对网站的监测
    无敌批处理
    Adsutil.vbs在脚本入侵中的妙用
    黑客高级技巧之Linux后门技术及实践
    ms 06014漏洞检测代码
    ms 06014漏洞检测代码
  • 原文地址:https://www.cnblogs.com/ccku/p/13452991.html
Copyright © 2011-2022 走看看