user2128
user2128

Reputation: 640

Docker image not running with https and tomcat

I am trying to run docker image with https URL instead of just http. The app is deployed in tomcat and I have generated docker image of it. When I run tomcat on https URL, it works fine but when I build docker image and try to run the image, the URL is not working.

Dockerfile

FROM tomcat:9.0.35

COPY conf/my-release-key.keystore /usr/local/tomcat/conf/my-release-key.keystore
COPY conf/server.xml /usr/local/tomcat/conf/server.xml
ADD webapps/placeholder-webapp.war /usr/local/tomcat/webapps/

EXPOSE 8080 8445
CMD ["catalina.sh","run"] 

server.xml

<Connector port="8445" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
           keystoreFile="conf/my-release-key.keystore" keystorePass="arcsight"
           clientAuth="false" sslEnabledProtocols="TLSv1.2,TLSv1.3" sslProtocol="TLS">
    </Connector>
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8445" />

Output on running docker image: enter image description here

I don't get any error on running docker image but I don't even see anything on accessing

Upvotes: 4

Views: 4171

Answers (3)

Rogier
Rogier

Reputation: 550

The ports you are using, 8445 and 8009 should be opened with EXPOSE in your Dockerfile.

Upvotes: 0

nischay goyal
nischay goyal

Reputation: 3480

Can you enable SSL in server.xml by adding the following code and then copy it in the container COPY server.xml /usr/local/tomcat/conf/

<!--
  <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />
-->

And apart from this EXPOSE 8443, in the Dockerfile instead of EXPOSE 8080, and then hit your service on https://localhost:8443

Upvotes: 0

CoderPraBhu
CoderPraBhu

Reputation: 346

You need to expose port 8445 in Dockerfile using EXPOSE 8445 and run the container using -p 8445:8445 to map local port 8445 to port 8445 running inside the container.

Your logs don't show that tomcat is aware that it needs to prepare a connector to run on port 8445. It must be using default server.xml configuration. You need to provide your server.xml to the container using something like following.

COPY server.xml /usr/local/tomcat/conf/

Upvotes: 1

Related Questions