How to set Java heap size (Xms/Xmx) inside Docker container?
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
See How to set JVM parameters?
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