I have a problem where I'm trying to pass environmental variable in Docker as command line argument for Spring, but not via -Drun.arguments
, but as normal command line argument because I need it in class that implements CommandLineRunner
and because as I read somewhere CommandLineRunner
only takes arguments that are written after your application .jar
file in command line, i.e. java -jar app.jar commandlineargument
.
In docker file I have this:
ENV SPRING_PROFILE="" \
JAVA_ARGS0=""
CMD ["java","-jar","-Dspring.profiles.active=${SPRING_PROFILE}","app.jar","--${JAVA_ARGS0}"]
When app starts it successfully reads the variable SPRING_PROFILE
and it starts with profile I put in configmap, but when I print my arguments in class that implements CommandLineRunner
, value of the argument is string ${JAVA_ARGS0}
instead of value from the variable.
I checked if the value is set for JAVA_ARGS0
and it is, so I'm wondering how am I supposed to pass the value.