Gnana
Gnana

Reputation: 2230

Docker jetty container JVM memory allocation

I am new to using Docker and have written a compose file for my application. It utilizes jetty and MySQL DB. I configured JVM memory for Jetty via JAVA_OPTS in the environment parameter. I thought the maximum memory setting for jetty JVM was 1GB. However, When I run the commands below, it shows that jetty has consumed 2 GB. Please help on how to configure the JVM memory for jetty and ensure the same.

docker-compose.yml

my-app:
  image: jetty
 environment:
     JAVA_OPTS: "-Xmx1024m -Xms128m"

Status CMD

docker stats $(docker ps|grep -v "NAMES"|awk '{ print $NF }'|tr "\n" " ")

CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O               BLOCK I/O
my-app           0.05%               2.188 GB / 10.56 GB   6.39%               12.66 kB / 1.584 kB   57 MB / 45.06 kB

Upvotes: 2

Views: 1987

Answers (2)

RIPAN
RIPAN

Reputation: 3896

When you run java inside container, its not only java, there are other things too, May be my answer is inappropriate to this context but I feel it might help someone in future. Please go through this link JVM memory optimization in Docker

Upvotes: 0

Carlos Rafael Ramirez
Carlos Rafael Ramirez

Reputation: 6234

You have a typo in your environment variable's name:

my-app:
  image: jetty
 environment:
   JAVA_OPTIONS: "-Xmx1024m -Xms128m"

Regards

Upvotes: 3

Related Questions