I'm trying to use Distroless as my base image and copy the apache tomcat application server package to the docker image and did all the necessary steps to create a docker image
which will deploy the war file to the tomcat webapps directory and start the tomcat server by using the following command
# Set the command to start Tomcat
CMD ["java", "-cp", "/usr/local/tomcat/bin/bootstrap.jar", "org.apache.catalina.startup.Bootstrap", "start"]
I was successfull in building the docker image, but when i ran the built image, i see an error saying "Error: Unable to access jarfile java".
With this error, i even tried changing the permission on the bootstrap.jar and copied the same to the apache tomcat bin directory in the dockerfile. After that
tried building and running the updated docker image, i got the same error as before.
Here is the Dockerfile which i have tried
# Use Distroless base image
FROM
gcr.io/distroless/java:11# Set the working directory in the container
WORKDIR /usr/local/tomcat
# Copy Tomcat files into the image
ADD apache-tomcat-9.0.87.tar.gz /usr/local/tomcat
# Copy the Tomcat files into the image
#COPY bootstrap.jar /usr/local/tomcat/bin/bootstrap.jar
COPY --chown=nonroot:nonroot bootstrap.jar /usr/local/tomcat/bin/bootstrap.jar
COPY app1.war /usr/local/tomcat/webapps/
ENV TOMCAT_MAJOR=9 \
TOMCAT_VERSION=9.0.87 \
CATALINA_HOME=/usr/local/tomcat \
JAVA_OPTS="-Xms1G -Xmx1G"
# Expose Tomcat port
EXPOSE 8080
# Set the command to start Tomcat
CMD ["java", "-cp", "/usr/local/tomcat/bin/bootstrap.jar", "org.apache.catalina.startup.Bootstrap", "start"]
Does anyone faced this issue before ? Appreciate any suggestion on this issue.
Thanks,
Arvind