0

I am trying set xmx and xms parameters for my java application which is inside docker container. When I try with adoptopenjdk it works fine.

With AdoptOpenjdk

Dockerfile :

FROM adoptopenjdk/openjdk8-openj9:alpine
WORKDIR /
ADD /target/*.jar app.jar
...

Docker compose

  myapp:
    image: myapp:dev
    container_name: myapp
    network_mode: "host"
    ports:
      - "PORT:PORT"
    environment:
      - OPENJ9_JAVA_OPTIONS=-Xmx1400m -Xms1400m -XX:+UseContainerSupport

enter image description here

But the same thing is not working with openjdk:8

Dockerfile

FROM openjdk:8
WORKDIR /
ADD /target/*.jar app.jar
...   

Docker Compose file

  myapp:
    image: myapp:dev
    container_name: myapp
    network_mode: "host"
    ports:
      - "PORT:PORT"
    environment:
      - JAVA_OPTS=-Xmx1400m -Xms1400m -XX:+UseContainerSupport

enter image description here

TheAkashKamble
  • 181
  • 2
  • 17
  • First question - is the environment variable actually set in the container? I'd check that directly, rather than inferring whether it's set by memory performance graphs. – passer-by Mar 25 '22 at 12:54
  • I am using docker compose file to set environment variables. This works in case of adoptopenjdk but not with openjdk8. Even tried with this command java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram" by doing docker exec. – TheAkashKamble Mar 25 '22 at 13:50
  • 1
    Did you check? Because that's what I actually asked. – passer-by Mar 27 '22 at 20:43

0 Answers0