I'm trying to create a docker image which sets a custom tomcat port (I know you can set an external port with the docker flag "-p 8888:8080" but for my use case I want to change the internal port as well).
When I try to start catalina.sh the run argument is being ignored for some reason.
Dockerfile:
# Tomcat 8 alpine dockerfile copied here (URL below)... minus the CMD line at the end
# https://github.com/docker-library/tomcat/blob/5f1abae99c0b1ebbd4f020bc4b5696619d948cfd/8.0/jre8-alpine/Dockerfile
ADD server.xml $CATALINA_HOME/conf/server.xml
ADD start-tomcat.sh /start-tomcat.sh
RUN chmod +x /start-tomcat.sh
ENTRYPOINT ["/bin/sh","/start-tomcat.sh"]
The tomcat file, server.xml, is the same as the default except for the line:
<Connector port="${port.http.nonssl}" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
start-tomcat.sh:
#!/bin/sh
export JAVA_OPTS=-Dport.http.nonssl=${PORT}
catalina.sh run
The image builds successfully, but when I run with
docker run -p 8888:8888 -e PORT=8888 customtomcat
I just get a list of catalina.sh commands as if I didn't give it an argument. I've also tried
/usr/local/tomcat/bin/catalina.sh run
sh -c "catalina.sh run"
sh -c "/usr/local/tomcat/bin/catalina.sh run"
cd /usr/local/tomcat/bin
./catalina.sh run
I'm pretty sure I'm missing something simple here. I'd guess it has something to do with the syntax, but maybe it has something to do with docker or alpine that I'm not aware of. This is my first time using alpine linux.
---Edit 1---
To explain my use case... I'm setting PORT after the docker image is created because it's being set by an apache mesos task. For my purposes I need to run the docker container (from marathon) in host mode, not bridged mode.
---Edit 2---
I modified things to only focus on my main issue. The docker file now only has the following appended to the end:
ADD start-tomcat.sh /start-tomcat.sh
RUN chmod +x /start-tomcat.sh
ENTRYPOINT ["/bin/sh","/start-tomcat.sh"]
And start-tomcat.sh:
#!/bin/bash
catalina.sh run
Still no luck.