Docker 安装 Tomcat
方法一、通过 Dockerfile构建
创建Dockerfile
首先,创建目录tomcat,用于存放后面的相关东西。
runoob@runoob:~$ mkdir -p ~/tomcat/webapps ~/tomcat/logs ~/tomcat/conf
webapps目录将映射为tomcat容器配置的应用程序目录
logs目录将映射为tomcat容器的日志目录
conf目录里的配置文件将映射为tomcat容器的配置文件
进入创建的tomcat目录,创建Dockerfile
FROM java:8-jre ENV CATALINA_HOME /usr/local/tomcat ENV PATH $CATALINA_HOME/bin:$PATH RUN mkdir -p "$CATALINA_HOME" WORKDIR $CATALINA_HOME # runtime dependencies for Tomcat Native Libraries # Tomcat Native 1.2+ requires a newer version of OpenSSL than debian:jessie has available (1.0.2g+) # see http://tomcat.10.x6.nabble.com/VOTE-Release-Apache-Tomcat-8-0-32-tp5046007p5046024.html (and following discussion) ENV OPENSSL_VERSION 1.0.2h-1 RUN { \ echo 'deb http://httpredir.debian.org/debian unstable main'; \ } > /etc/apt/sources.list.d/unstable.list \ && { \ # add a negative "Pin-Priority" so that we never ever get packages from unstable unless we explicitly request them echo 'Package: *'; \ echo 'Pin: release a=unstable'; \ echo 'Pin-Priority: -10'; \ echo; \ # except OpenSSL, which is the reason we're here