Can we make docker port image configurable?
Description
We have to run the container in host network mode, so we cannot remap 8080
Priority
I have no budget and there's no rush, please add this feature for free
More information
I can prepare PR if it is convenient. In fact changes required are small
I don't think any code changes to the repo are necessary for you to facilitate this change on your own. I confirmed this works in a sandbox.
Change the Dockerfile from this:
FROM tomcat:10.1.16-jre17-temurin-jammy
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends graphviz
RUN sed -i 's/port="8080"/port="8080" maxPostSize="10485760"/' conf/server.xml
ADD build/libs/structurizr-onpremises.war /usr/local/tomcat/webapps/ROOT.war
ENV CATALINA_OPTS="-Xms512M -Xmx512M"
EXPOSE 8080
CMD ["catalina.sh", "run"]
To This (Assuming desiring port 8282 instead of 8080):
FROM tomcat:10.1.16-jre17-temurin-jammy
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends graphviz
RUN sed -i 's/port="8080"/port="8080" maxPostSize="10485760"/' conf/server.xml
RUN sed -i 's/port="8080"/port="8282"/' conf/server.xml
ADD build/libs/structurizr-onpremises.war /usr/local/tomcat/webapps/ROOT.war
ENV CATALINA_OPTS="-Xms512M -Xmx512M"
EXPOSE 8282
CMD ["catalina.sh", "run"]
Yes, the diff can switch the app to another hardcoded port. Thank you.But to make this work:
- You need to build and support your own image of structurizr
- The port remains to be hardcoded in the image. You can't override it on container start
I'd be interested to see what your solution to this problem is. I suggest you proceed with the PR you proposed.
I tested the scheme with variable substitution
any update?
I've made the port configurable via an environment variable named PORT and the built-in setenv.sh mechanism, which gets sourced inside catalina.sh. Thanks for the PR though.