docker pull 拉取的tomcat 没有生成日志,自己就手写了一个tocmat dockerfile文件,实测有日志生成

一、dockfile 文件以及解释如下 

FROM openjdk:8-jre

MAINTAINER zyj

ENV JAVA_HOME /docker-java-home
ENV CATALINA_HOME /opt/tomcat 
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$CATALINA_HOME/scripts

#时区 
RUN echo "Asia/Shanghai" > /etc/timezone

RUN mv /etc/localtime /etc/localtime_bak

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

#TOMCAT 
ENV TOMCAT_MAJOR 8
ENV TOMCAT_VERSION 8.5.35

RUN wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.41/bin/apache-tomcat-8.5.41.tar.gz && \
 tar -zxvf apache-tomcat-8.5.41.tar.gz && \
 rm apache-tomcat*.tar.gz && \
 mv apache-tomcat* ${CATALINA_HOME} 

RUN chmod +x ${CATALINA_HOME}/bin/*sh

RUN chmod 777 ${CATALINA_HOME}/logs/

RUN chmod 777 ${CATALINA_HOME}/webapps/

#设置用户名密码 admin 
ADD  tomcat-users.xml /opt/tomcat/conf/

#远程访问 
ADD  context.xml /opt/tomcat/webapps/manager/META-INF/

ENV LANG zh_CN.UTF-8

#开放端口 
EXPOSE 8080

# Launch Tomcat

WORKDIR /opt/tomcat/bin
CMD ["catalina.sh","run"]

注意:该docker 需要引用外部文件

详见 github

二、dockerfile 编译命令

docker build -f dockerfile -t zyj/tomcat .

三、运行命令

docker run -d -p 8080:8080 --name tomcat8
-v /opt/docker-tomcat/logs/:/opt/tomcat/logs/ -v /opt/docker-tomcat/webapps/:/opt/tomcat/webapps/ -v /opt/docker-tomcat/context.xml:/opt/tomcat/webapps/manager/META-INF/context.xml -v /opt/docker-tomcat/tomcat-users.xml:/opt/tomcat/conf/tomcat-users.xml --privileged=true zyj/tomcat

 

你可能感兴趣的:(docker)