Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing JVM args to Docker image of Spring boot app on Kubernetes

I am trying to pass JVM args to Docker image of Spring boot app on Kubernetes. Specifically, I wanted to pass these three arguments:

-Djavax.net.ssl.trustStore=/certs/truststore/cacerts
-Djavax.net.ssl.trustStorePassword=password
-Djavax.net.debug=ssl

I tried adding it to "env" section with name as "JAVA_OPTS", "JDK_JAVA_OPTIONS" and "JAVA_TOOL_OPTIONS", none of which seemed like they were working.

I also tried adding it under "args" section, that did not work either. At best I get no change in behaviour at all, at worst my pods won't start at all with this error:

Error: failed to create containerd task: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: setenv: invalid argument: unknown

Entry point in Dockerfile is defined as such:

ENTRYPOINT ["java","-jar","/app/appname-exec.jar"]

Any ideas?

like image 389
lovrodoe Avatar asked Oct 24 '25 09:10

lovrodoe


1 Answers

To override the container's default ENTRYPOINT setting, I sometimes do the following:

containers:
  - name: my-container
    image: mycontainer:latest
    command: ["java"]
    args: ["-Djavax...", "-Djavax...", "-jar", "myapp.jar"]

You can define content in the manifest that you would describe in a Dockerfile. In args section, you can describe as many settings as you want.

like image 189
Daigo Avatar answered Oct 25 '25 23:10

Daigo