fabric8io-images / java

Java Base Images
Apache License 2.0
176 stars 98 forks source link

Impossible to pass JAVA_OPTIONS with spaces(?) #66

Open karel1980 opened 3 years ago

karel1980 commented 3 years ago

I'm trying to run java -Dfoo="one two three" but I didn't manage to find the right combination of quotes or escapes to make this work

Given: docker run -e JAVA_MAIN_CLASS=Main -e JAVA_OPTIONS="-Dfoo=one two three" -i -t fabric8/java-alpine-openjdk8-jdk:1.8.0 /deployments/run-java.sh

Actual output: exec java -Dfoo=one two three -javaagent:/opt/agent-bond/agent-bond.jar=jolokia{{host=0.0.0.0}},jmx_exporter{{9779:/opt/agent-bond/jmx_exporter_config.yml}} -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError -cp .:/deployments/* Main Error: Could not find or load main class two

Expected output: ... Error: Could not find or load main class Main

I tried to add backslashes and quotes in various combinations, but I never got it right. I suspect it has something to do with the 'normalize spaces' stuff in java_options of /deployments/run-java.sh

karel1980 commented 3 years ago

I should add that spaces should not be normalised too aggressively:

If a user wants to pass-Dfoo="one <multiple spaces> two <multiple spaces> three" then the spaces should not be stripped. (Had to do this edit this a few times because markdown is aggressively removing spaces. How ironic)