containers
containers copied to clipboard
[bitnami/tomcat:9.0.89] Can't set JAVA_OPTS in tomcat image, always overwritten by default.
Name and Version
bitnami/tomcat:9.0.89
What architecture are you using?
amd64
What steps will reproduce the bug?
- Run the container with this command to get an interactive shell and set JAVA_OPTS enviroment:
docker run -it -e JAVA_OPTS="-XX:MaxRAMPercentage=70 -XX:+UseZGC -XX:+ZGenerational" --name tomcat bitnami/tomcat:latest bash - Print the JAVA_OPTS to ensure it is set correctly:
echo $JAVA_OPTS - Print tomcats
setenv.sh, which is called bycatalina.shbefore it starts the tomcat server:cat /opt/bitnami/tomcat/bin/setenv.sh - See in line 6, that JAVA_OPTS gets overwritten.
What is the expected behavior?
I expect that the JAVA_OPTS that I set on the container are also set on the tomcat process.
What do you see instead?
-Djava.awt.headless=true -XX:+UseG1GC -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true -Duser.home=/opt/bitnami/tomcat is always set, regardles what the JAVA_OPTS env holds.
Additional information
JAVA_OPTS is listed in the section for the customizable environment variables, but it currently is not customizable.
There is a setenv.sh template which sets JAVA_OPTS to the default value at the image buildtime.
- Tomcats setenv.sh template: https://github.com/bitnami/containers/blob/main/bitnami/tomcat/9.0/debian-12/rootfs/opt/bitnami/scripts/tomcat/bitnami-templates/setenv.sh.tpl
- Template gets rendered in: https://github.com/bitnami/containers/blob/main/bitnami/tomcat/9.0/debian-12/rootfs/opt/bitnami/scripts/tomcat/postunpack.sh#L44
- This calls tomcat-env.sh at buildtime, which sets JAVA_OPTS to the default.
- Which is run in the Dockerfile: https://github.com/bitnami/containers/blob/main/bitnami/tomcat/9.0/debian-12/Dockerfile#L53
We need to overwrite the JAVA_OPTS to change the garbage collector.