2

I got this list of JVM params from the following answer https://stackoverflow.com/a/35108974/7809534:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

And I would like to run them in docker-compose.

This is what I tried:

environment:
  - JAVA_TOOL_OPTIONS="-Dcom.sun.management.jmxremote"
  - JAVA_TOOL_OPTIONS="-Dcom.sun.management.jmxremote.port=9010"
  - JAVA_TOOL_OPTIONS="-Dcom.sun.management.jmxremote.local.only=false"
  - JAVA_TOOL_OPTIONS="-Dcom.sun.management.jmxremote.authenticate=false"
  - JAVA_TOOL_OPTIONS="-Dcom.sun.management.jmxremote.ssl=false"

But it is not working.

How can I do it?

Jakov
  • 879
  • 2
  • 17
  • 36
  • 1
    multiple JAVA_TOOL_OPTIONS are overriding each other so you have to combine them all in one single entry, separated by spaces. – fly2matrix Feb 16 '22 at 16:11

2 Answers2

2

Eventually, I managed to find a solution.

Here it is:

environment:
    - JAVA_TOOL_OPTIONS=
        -Dcom.sun.management.jmxremote
        -Dcom.sun.management.jmxremote.port=9010
        -Dcom.sun.management.jmxremote.local.only=false
        -Dcom.sun.management.jmxremote.authenticate=false
        -Dcom.sun.management.jmxremote.ssl=false
Jakov
  • 879
  • 2
  • 17
  • 36
1

Use YAML multiline string operator '>' to merge the lines

environment:
  JAVA_TOOL_OPTIONS: >
    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.port=9010
    -Dcom.sun.management.jmxremote.local.only=false
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false
Rakesh Gupta
  • 3,507
  • 3
  • 18
  • 24