标签:nta zip cmd route www add group linux profile
构建Tomcat镜像 FROM ubuntu-base:20.04
MAINTAINER shitouweb "shitouweb@126.com"
ADD jdk-8u251-linux-x64.tar.gz /usr/local/src/
RUN ln -sv /usr/local/src/jdk1.8.0_251 /usr/local/jdk
ADD profile /etc/profile
ENV JAVA_HOME /usr/local/jdk
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/lib/:$JRE_HOME/lib/
ENV PATH $PATH:$JAVA_HOME/bin
RUN rm -rf /etc/localtime && ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
vim /opt/dockerfile/web/jdk/jdk-8U251/profile #可以在虚拟机中先搭建java环境变量然后复制profile文件即可,添加以下
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$JAVA_HOME/jre/lib/rt.jar:$JRE_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
vim /opt/dockerfile/web/jdk/jdk-8U251/build-command.sh
#!/bin/bash
sudo docker build -t ubuntu20.04-jkd:8U251 .
3.构建Tomcat镜像
mkdir /opt/dockerfile/web/tomcat/tomcat-9.0.35
vim /opt/dockerfile/web/tomcat/tomcat-9.0.35/Dockerfile
FROM ubuntu20.04-jkd:8U251
LABEL shitouweb shitouweb@126.com
ADD apache-tomcat-9.0.35.tar.gz /apps
RUN ln -sv /apps/apache-tomcat-9.0.35 /apps/tomcat
vim /opt/dockerfile/web/tomcat/tomcat-9.0.35/build-command.sh
#!/bin/bash
sudo docker build -t ubuntu20.04-tomcat:9.0.35 .
4.构建业务镜像
mkdir /opt/dockerfile/web/tomcat/tomcat-app1
vim /opt/dockerfile/web/tomcat/tomcat-app1/Dockerfile
FROM ubuntu20.04-tomcat:9.0.35
LABEL shitouweb shitouweb@126.com
ADD server.xml /apps/tomcat/conf/server.xml
ADD docker-1.tar.gz /data/tomcat/webapps
ADD run_tomcat.sh /apps/tomcat/bin/run_tomcat.sh
RUN chown -R www:www /apps/
EXPOSE 8080 8005
CMD ["/apps/tomcat/bin/run_tomcat.sh"]
vim /opt/dockerfile/web/tomcat/tomcat-app1/buile-command.sh
#!/bin/bash
sudo docker build -t ubuntu20.04-tomcat0.0.35-webapps:1 .
vim /opt/dockerfile/web/tomcat/tomcat-app1/run_tomcat.sh可执行文件必须增加执行权限,否则在容器中不能执行
su -c ‘/apps/tomcat/bin/catalina.sh start‘ - www
tail -f /etc/hosts
修改server.xml
<Host name="localhost" appBase="/data/tomcat/webapps"
unpackWARs="false" autoDeploy="false">
注意:在DockerFile中写入的CMD后面的命令不执行主要是因为启动的时候指定了shell
标签:nta zip cmd route www add group linux profile
原文地址:https://blog.51cto.com/shitouweb/2501639