4

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?

1
  • 1
    multiple JAVA_TOOL_OPTIONS are overriding each other so you have to combine them all in one single entry, separated by spaces. Commented Feb 16, 2022 at 16:11

2 Answers 2

7

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
Sign up to request clarification or add additional context in comments.

1 Comment

OMG, I had tried like 20 other options until I found your answer, which is the only one that worked. I still don't get why the normal YAML multiline value does not work, like the one in the other answer here. I needed it for Tomcat's JAVA_OPTS, but it seems to work in the same way
2

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

2 Comments

This was not working for me, but it was pretty close to the working solution
This working with me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.