I want to create a docker container to install Tomcat within it. It seems that my docker compiles with no problem and I am also able to run tomcat with no problems reported through the logs. Yet, if I try to open tomcat I get a 404 error. I do not know what I am missing. Any ideas, please? The next is the content of my Dockerfile:
FROM centos:7
MAINTAINER joseccz
EXPOSE 8080
EXPOSE 8009
RUN yum install -y mc
RUN yum install -y wget
# RUN yum install -y apr-devel openssl-devel
RUN yum install -y gcc
RUN yum install epel-release -y
RUN yum install dnf -y
RUN yum install net-tools -y
RUN yum install libtool -y
ENV JAVA_HOME /opt/javaSDK
ENV JRE_HOME ${JAVA_HOME}/jre
ADD javaSDK ${JAVA_HOME}
ADD tomcat.service /etc/systemd/system/
# ----------------------------------------------- Copy Tomcat Files to /opt/tomcat -----------------------------------------------
ENV TOMCAT_MAJOR 8
ENV TOMCAT_VERSION 8.5.45
ENV CATALINA_HOME /opt/tomcat
# http://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz
ENV PATH $JAVA_HOME/bin:$CATALINA_HOME/bin:$CATALINA_HOME/lib:$PATH
RUN wget http://www-us.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz && \
tar -xvf apache-tomcat-${TOMCAT_VERSION}.tar.gz
RUN mv apache-tomcat-${TOMCAT_VERSION} tomcat
RUN rm apache-tomcat*.tar.gz
RUN mv tomcat /opt/tomcat
# --------------------------------------------------------------------------------------------------------------------------------
RUN groupadd tomcat
RUN useradd -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
# RUN wget https://rpmfind.net/linux/mageia/distrib/cauldron/x86_64/media/core/release/tomcat-native-1.2.23-1.mga8.x86_64.rpm
# RUN rpm -i tomcat-native-1.2.23-1.mga8.x86_64.rpm
# RUN cd /opt/tomcat
RUN chgrp -R tomcat /opt/tomcat/conf
RUN chmod g+rwx /opt/tomcat/conf
RUN chmod g+r /opt/tomcat/conf/*
RUN chown -R tomcat /opt/tomcat/logs/ /opt/tomcat/temp/ /opt/tomcat/webapps/ /opt/tomcat/work/
RUN chgrp -R tomcat /opt/tomcat/bin
RUN chgrp -R tomcat /opt/tomcat/lib
RUN chmod g+rwx /opt/tomcat/bin
RUN chmod g+r /opt/tomcat/bin/*
#----------------------------------Create /opt/software folder for addinitonal soft needed by Tomcat ------------------------------
RUN mkdir /opt/software
#---------------------------------------- copy and compile Development tools ---------------------------------------------------------
RUN yum groupinstall "Development Tools" -y
#---------------------------------------- Donwload and install open ssl ------------------------------------------------------------
RUN wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
RUN tar -xvf openssl-1.0.2l.tar.gz
RUN mv openssl-1.0.2l openssl
RUN mv openssl /opt/software/openssl
RUN cd /opt/software/openssl && ./config -fPIC --prefix=/opt/software/ --openssldir=/opt/software/ && make && make install
#---------------------------------------- Donwload and install open apr ------------------------------------------------------------
ENV APRVERSION 1.6.5
RUN wget http://apache.mirrors.ionfish.org//apr/apr-${APRVERSION}.tar.gz
RUN tar -xvf apr-${APRVERSION}.tar.gz
RUN mv apr-${APRVERSION} apr
RUN mv apr /opt/software/apr
RUN cd /opt/software/apr/ && \
./configure --prefix=/opt/software/ && \
make && make install
#------------------------------------------ Copy TOMCAT native
# compiling tomcat native
RUN cd ${CATALINA_HOME}/bin/ && \
tar -xvf tomcat-native.tar.gz && \
cd tomcat-native-1.2.23-src/native/ && \
./configure --with-apr=/opt/software/ --with-java-home=/opt/javaSDK/ --with-ssl=/opt/software --prefix=/opt/tomcat && \
make && \
make install
ADD setenv.sh /opt/tomcat/bin/
my setenv.sh file content is:
export JAVA_HOME=/opt/javaSDK
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
export LD_LIBRARY_PATH