title: Docker OpenJDK -Xmx or
body: <p>I am trying to get a service running in a container, but ran into the <code>OutOfMemoryError: Java heap space</code> when the service in the container starts up (it does some memory intensive stuff).</p>
  
  <p>I am trying to add the options for <code>-Xmx1024 -Xms1024</code>, but that didn't work.</p>
  
  <p>I also attempted to use</p>
  
  <pre><code>-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
  </code></pre>
  
  <p>as the <a href="https://hub.docker.com/r/_/openjdk/" rel="nofollow noreferrer">OpenJDK Docker Hub</a> documentation mentions, however when I run that, it fails with the following error:</p>
  
  <pre><code>Unrecognized VM option 'UnlockExperimentalVMOptions XX:+UseCGroupMemoryLimitForHeap'
  </code></pre>
  
  <p>The current <code>Dockerfile</code> that I am using looks like the following</p>
  
  <pre><code>FROM openjdk:8u131
  
  ...
  
  ...
  
  CMD ["java","-XshowSettings:vm -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap","-jar", "target/my-jar.jar"]
  </code></pre>