How to set Java heap size (Xms/Xmx) inside Docker container?
Note that in a docker-compose.yml
file - you'll need to leave out the double-quotes:
environment: - JVM_OPTS=-Xmx12g -Xms12g -XX:MaxPermSize=1024m
or
environment: - CATALINA_OPTS=-Xmx12g -Xms12g -XX:MaxPermSize=1024m
I agree that it depends on what container you're using. If you are using the official Tomcat image, it looks like it's simple enough, you will need to pass the JAVA_OPTS
environment variable with your heap settings:
docker run --rm -e JAVA_OPTS='-Xmx1g' tomcat
You can also just place those settings in your image so something like the following would exist in your Dockerfile:
ENV JAVA_OPTS="-XX:PermSize=1024m -XX:MaxPermSize=512m"