FROM conetos VOLUMES['volumes01','volumes02'] 容器挂载相互同步
先启动一个 docker run -it --name docker01 centos:1.0 在启动一个 docker run -it --name docker02 --volumes-from docker01 centos:1.0 --volumes-from 实现数据卷挂载同步 相当于实现了继承(docker02 extends docker01)编写dockerfile脚本
FROM centos MAINTAINER kuangshen<[email protected]> #把宿主机当前上下文的read.txt拷贝到容器/usr/local/路径下 COPY read.txt /usr/local/cincontainer.txt #把java与tomcat添加到容器中 ADD jdk-8u351-linux-x64.tar.gz /usr/local/ ADD apache-tomcat-9.0.22.tar.gz /usr/local/ #安装vim编辑器 RUN yum -y install vim #设置工作访问时候的WORKDIR路径,登录落脚点 ENV MYPATH /usr/local WORKDIR $MYPATH #配置java与tomcat环境变量 ENV JAVA_HOME /usr/local/jdk1.8.0_351 ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.22 ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.22 ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin #容器运行时监听的端口 EXPOSE 8080 #启动时运行tomcat # ENTRYPOINT ["/usr/local/apache-tomcat-9.0.22/bin/startup.sh" ] # CMD ["/usr/local/apache-tomcat-9.0.22/bin/catalina.sh","run"] CMD /usr/local/apache-tomcat-9.0.22/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.22/bin/logs/catalina.out
启动自定义tomcat
docker run -d -p 9090:8080 --name mytomcat -v /home/huoziqi/build/tomcat/test:/usr/local/apache-tomcat-9.0.70/webapps/test -v /home/huoziqi/build/tomcat/tomcatlogs:/usr/local/apache-tomcat-9.0.70/logs diytomcat:1.0
测试
linux本机curl localhost:9090 外部测试:http://192.168.2.8:9090/
标签:22,tomcat,示例,dockerfile,9.0,usr,apache,local From: https://www.cnblogs.com/qijiangforever/p/17418911.html