Reputation: 2313
I need to run a docker image where I pass a bunch of jvm configurations to a jar file. I'm passing the configs via -e parameters as the example bellow.
Dockerfile:
FROM openjdk:9-jre
COPY test.jar /
CMD java -jar -DinstallationDate=$INSTALLATION_DATE /test.jar
Run command:
docker run -e INSTALLATION_DATE="03.05.10.2019 15:00:00" space
The problem is that when I run this, it gives me the following error:
Error: Unable to access jarfile 15:00:00
I tried running it with the json notation, like:
docker run -e ["INSTALLATION_DATE","03.05.10.2019 15:00:00"] space
It doesn't give me an error, but the parameter comes as an empty string. I also tried to escape the space char with "\", but still didn't work.
Anyone knows how can I send this parameter to the jar execution inside the docker container? Is there another approach to this?
Upvotes: 2
Views: 6775
Reputation: 1435
The problem is likely occurring because the CMD
in your Dockerfile
:
CMD java -jar -DinstallationDate=$INSTALLATION_DATE /test.jar
...is subject to word splitting after the variable $INSTALLATION_DATE
is expanded. In order to turn off word splitting for that second argument to java
, consider enclosing the variable in double quotes:
CMD java -jar -DinstallationDate="$INSTALLATION_DATE" /test.jar
Upvotes: 4