How to set Java heap size (Xms/Xmx) inside Docker container?

tung picture tung · Apr 28, 2015 · Viewed 73.6k times · Source

As of raising this question, Docker looks to be new enough to not have answers to this question on the net. The only place I found is this article in which the author is saying it is hard, and that's it.

Answer

hawkeye picture hawkeye · Aug 25, 2016

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