<p>I'm working with Docker and Kubernetes on AWS (cloudformation yaml)</p>
<p>Yaml</p>
<pre><code>...
resources:
  requests:
    memory: &quot;4Gi&quot;
    cpu: &quot;0.5&quot;
  limits:
    memory: &quot;4Gi&quot;
    cpu: &quot;0.5&quot;
</code></pre>
<p>Dockerfile</p>
<pre><code>FROM amazonlinux:latest
RUN yum -y install java-1.8.0
EXPOSE 8103
ADD myapp.jar
ENTRYPOINT [&quot;java&quot;,&quot;-XX:MinRAMPercentage=50.0&quot;,&quot;-XX:MaxRAMPercentage=80.0&quot;,&quot;-jar&quot;,&quot;myapp.jar&quot;]
</code></pre>
<p>Follow you can find the version of java &quot;1.8.0_282&quot; from the bash of my pod</p>
<pre><code>bash-4.2# java -XX:+PrintFlagsFinal  -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
 intx CompilerThreadStackSize                   = 0                                   {pd product}
uintx ErgoHeapSizeLimit                         = 0                                   {product}
uintx HeapSizePerGCThread                       = 87241520                            {product}
uintx InitialHeapSize                          := 67108864                            {product}
uintx LargePageHeapSizeThreshold                = 134217728                           {product}
uintx MaxHeapSize                              := 1073741824                          {product}
 intx ThreadStackSize                           = 1024                                {pd product}
 intx VMThreadStackSize                         = 1024                                {pd product}
openjdk version &quot;1.8.0_282&quot;
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
</code></pre>
<p>I read this <a href="https://merikan.com/2019/04/jvm-in-a-container/#java-10" rel="noreferrer">blog</a> where the author has explained that <em>&quot;If you are running Java 8 update 191 or later, or Java 10, 11,12, 13 etc. you must NOT use the UseCGroupMemoryLimitForHeap option. Instead you should use the UseContainerSupport that is activated by default.&quot;</em></p>
<p>For this reason I have added the options &quot;-XX:MinRAMPercentage=50.0&quot;,&quot;-XX:MaxRAMPercentage=80.0&quot; in my ENTRYPOINT instruction.</p>
<pre><code>ENTRYPOINT [&quot;java&quot;,&quot;-XX:MinRAMPercentage=50.0&quot;,&quot;-XX:MaxRAMPercentage=80.0&quot;,&quot;-jar&quot;,&quot;myapp.jar&quot;]
</code></pre>
<p>Unfortunately the UseContainerSupport values didn't change on my pod as you can see follow</p>
<pre><code>bash-4.2# java -XX:+PrintFlagsFinal  -version | grep -E &quot;UseContainerSupport | InitialRAMPercentage | MaxRAMPercentage | MinRAMPercentage&quot;
double InitialRAMPercentage                      = 1.562500                            {product}
double MaxRAMPercentage                          = 25.000000                           {product}
double MinRAMPercentage                          = 50.000000                           {product}
  bool UseContainerSupport                       = true                                {product}
openjdk version &quot;1.8.0_282&quot;
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
</code></pre>
<p>I have also tried to add JAVA_OPTS in my YAML as following but nothing change</p>
<pre><code>env:
  - name: JAVA_OPTS
    value: &quot;-XX:MinRAMPercentage=50.0 -XX:MaxRAMPercentage=80.0&quot; 
</code></pre>
<p>Finally the question :-)</p>
<p>How and where have I to set the -XX:MinRAMPercentage and -XX:MaxRAMPercentage options in order to modify the default value of MaxRAMPercentage? I want use 3Gi of memory of 4Gi dedicated (on yaml)</p>
<p>Thanks to everyone</p>

<p>Please change your env variable from <code>JAVA_OPTS</code> to <code>JAVA_TOOL_OPTIONS</code>.
This worked for me with Java8.</p>
