Dockfile打包带tdengine驱动的tomcat自定义镜像
Posted gsls200808
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dockfile打包带tdengine驱动的tomcat自定义镜像相关的知识,希望对你有一定的参考价值。
普通的tomcat版本跑带tdengine的驱动是跑不起来的,需要自定义打包tdengine客户端进去才可以。
Dockfile内容如下
FROM centos:7.5.1804
MAINTAINER xxx "xxx@qq.com"
ENV REFRESHED_AT 2018-11-27
WORKDIR /usr/local
RUN mkdir jdk
ADD jdk-8u202-linux-x64.tar.gz /usr/local/jdk
ADD apache-tomcat-8.5.40.tar.gz /usr/local/
RUN ln -s /usr/local/apache-tomcat-8.5.40 /usr/local/tomcat
ENV JAVA_HOME=/usr/local/jdk/jdk1.8.0_202
ENV JRE_HOME=$JAVA_HOME/jre
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
ENV PATH=/sbin:$JAVA_HOME/bin:$PATH
RUN chmod +x /usr/local/tomcat/bin/catalina.sh
RUN mkdir tdengineclient
ADD TDengine-client-2.4.0.12-Linux-x64.tar.gz /usr/local/
RUN cd /usr/local/TDengine-client-2.4.0.12/ && ./install_client.sh
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 8080
ENTRYPOINT ["/usr/local/tomcat/bin/catalina.sh","run"]
Dockefile同级目录需要有
jdk-8u202-linux-x64.tar.gz
apache-tomcat-8.5.40.tar.gz
TDengine-client-2.4.0.12-Linux-x64.tar.gz
最后执行如下命令完成打包
docker build -t tomcat:8 .
启动tomcat命令如下
docker run -itd \\
--name=my-tomcat \\
-v "/root/my/tomcat/conf:/usr/local/apache-tomcat-8.5.40/conf" \\
-v "/root/my/tomcat/webapps:/usr/local/apache-tomcat-8.5.40/webapps" \\
-v "/root/my/tomcat/data/logs:/data/logs" \\
-p '8080:8080' \\
--privileged=true \\
--restart=always \\
tomcat:8
docker-compose yml配置如下
version: '2'
services:
my-tomcat:
container_name: my-tomcat
image: tomcat:8
volumes:
- "/root/my/tomcat/conf:/usr/local//apache-tomcat-8.5.40/conf"
- "/root/my/tomcat/webapps:/usr/local//apache-tomcat-8.5.40/webapps"
- "/root/my/tomcat/data/logs:/data/logs"
ports:
- '8080:8080'
environment:
- TZ=Asia/Shanghai
privileged: true
restart: always
其中/root/my/tomcat/conf 为tomcat的config目录,/root/my/tomcat/webapps为tomcat的webapp目录
以上是关于Dockfile打包带tdengine驱动的tomcat自定义镜像的主要内容,如果未能解决你的问题,请参考以下文章