Docker自定义一个Tomcat镜像

Docker自定义一个Tomcat镜像

本文是基于CentOS 7.3系统环境,进行Docker的学习和使用

  • CentOS 7.3
  • Docker-ce

一、自定义一个Tomcat镜像

(1) 创建一个目录

mkdir -p /data/mydockerfile/tomcat9

(2) 下载Tomcat9和jdk

apache-tomcat-9.0.30.tar.gz
jdk-8u201-linux-x64.tar.gz

cp /root/apache-tomcat-9.0.30.tar.gz /data/mydockerfile/tomcat9
cp /root/jdk-8u201-linux-x64.tar.gz /data/mydockerfile/tomcat9

(3) 编写Dockerfile

FROM centos
MAINTAINER xuzheng<[email protected]>
COPY readme.txt /usr/local/README.txt
ADD jdk-8u201-linux-x64.tar.gz /usr/local
ADD apache-tomcat-9.0.30.tar.gz /usr/local
RUN yum -y install vim
ENV MYPATH /usr/local
WORKDIR MYPATH

ENV JAVA_HOME /usr/local/jdk1.8.0_201
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.30
ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.30
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin

EXPOSE 8080

CMD /usr/local/apache-tomcat-9.0.30/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.30/bin/logs/catalina.out

(4) 构建镜像

docker build -t xztomcat9 .

你可能感兴趣的:(Docker)