cannot contain "Catalina sh not working in java devel"

31 views Asked by At

i am using dockerfile

FROM redhat/ubi8
MAINTAINER "[email protected]"
RUN yum update -y
RUN yum install java-devel -y
RUN yum install unzip  -y
RUN mkdir /server
COPY Dockerfile /server
COPY apache-tomcat-10.1.19.tar.gz /server
WORKDIR /server
ADD apache-tomcat-10.1.19.tar.gz /server
RUN tar xfh /server/apache-tomcat-10.1.19.tar.gz
CMD ["/server/apache-tomcat-10.1.19/bin/catalina.sh","run"]
EXPOSE 8080 8085 8081

In this file docker build is successful but facing error at the time of container build

# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                      PORTS     NAMES
49ca5c2108bb   cc606115c681   "/server/apache-tomc…"   11 seconds ago   Exited (1) 10 seconds ago             t1
[root@ip-devil. ~]# docker logs 49ca5c2108bb
Using CATALINA_BASE:   /server/apache-tomcat-10.1.19
Using CATALINA_HOME:   /server/apache-tomcat-10.1.19
Using CATALINA_TMPDIR: /server/apache-tomcat-10.1.19/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /server/apache-tomcat-10.1.19/bin/bootstrap.jar:/server/apache-tomcat-10.1.19/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Unrecognised option: --add-opens=java.base/java.lang=ALL-UNNAMED
# Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

please suggest how to solve and run the container

1

There are 1 answers

0
datawookie On

Use the openjdk image since it already has the Java development environment. Also download the Apache Tomcat distribution rather than using a local copy.

FROM openjdk:23-jdk-slim

RUN apt-get update -q && \
    apt-get install -y -q wget

WORKDIR /server

RUN wget -q https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.19/bin/apache-tomcat-10.1.19.tar.gz && \
    tar xfh /server/apache-tomcat-10.1.19.tar.gz

CMD ["/server/apache-tomcat-10.1.19/bin/catalina.sh","run"]