JAVA_OPTS/CATALINA_OPTS parameters not working with docker-compose.yml
<p>I build my image using below Dockerfile:</p>

<pre><code>FROM java:jre-alpine
WORKDIR /target
ADD /target/test.jar test.jar
RUN sh -c 'touch /test.jar'
ENTRYPOINT ["java","/target/test.jar"]
</code></pre>

<p>And in my docker-compose.yml I have specified:</p>

<pre><code>environment:
    - CATALINA_OPTS=-Xmx256m -Xms128m
</code></pre>

<p>However when I use docker stats to check the memory usage, my docker container consumes much more memory than 256m.</p>

<p>BUT If I specify the JVM parameter in Dockerfile directly(see below), then docker stats shows the correct number:</p>

<pre><code>FROM java:jre-alpine
WORKDIR /target
ADD /target/test.jar test.jar
RUN sh -c 'touch /test.jar'
ENTRYPOINT ["java","-Xmx512m","/target/test.jar"]
</code></pre>

<p>Could you give me some hints? I do not want to hardcode the -Xmx parameter in Dockerfile.</p>