<p>I have a Docker image of a Spring Boot app running in Kubernetes cluster. I'm trying to override an entrypoint.</p>
<p>My original entrypoint was</p>
<pre><code>ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;/app/myapp-exec.jar&quot;]
</code></pre>
<p>So I tried to override it in spec of deployment because I need to pass some JVM arguments:</p>
<pre><code>      command: [&quot;sh&quot;, &quot;-c&quot;, &quot;java ${JAVA_OPTS} -jar /app/myapp-exec.jar ${0} ${@}&quot;]
      args:
        - --spring[0].property=property_value
      env:
        - name: &quot;JAVA_OPTS&quot;
          value: &quot;...jvm options...&quot;
        - name: spring.property1
          value: property_value
        - name: spring.property2
          value: property_value
</code></pre>
<p>My application is launched, but properties defined under env that used to get passed to Spring app with original entry point are not passed anymore. According to <a href="https://spring.io/guides/topicals/spring-boot-docker/" rel="nofollow noreferrer">Spring Docker documentation</a>, ${0} ${@} should fix my exact issue, but it doesn't seem to work.</p>
<p>Any help is appreciated.</p>

lovrodoe
<p>You can get around the various shell-quoting problems by making the main container process a very short shell script:</p>
<pre class="lang-sh prettyprint-override"><code>#!/bin/sh
exec java $JAVA_OPTS -jar /myapp-exec.jar &quot;$@&quot;
</code></pre>
<p>Then your Dockerfile can specify this script as the main container command, instead of trying to shoehorn it into the <code>ENTRYPOINT</code>/<code>CMD</code> split somehow.</p>
<pre class="lang-sh prettyprint-override"><code>COPY run-myapp.sh .
CMD [&quot;./run-myapp.sh&quot;]  # (I tend to prefer CMD to ENTRYPOINT)
</code></pre>
<p>If the only things you're trying to pass as command-line arguments are Spring properties, you can <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.typesafe-configuration-properties.relaxed-binding" rel="nofollow noreferrer">specify those as environment variables</a>; this is much easier than trying to figure out the command-line setup.  So for your use case, I would specify</p>
<pre class="lang-yaml prettyprint-override"><code>containers:
  - name: myapp
    image: registry.example.com/myapp:20211203
    # neither command: nor args:
    env:
      - name: &quot;JAVA_OPTS&quot;
        value: &quot;...jvm options...&quot;
      - name: SPRING_PROPERTY1
        value: property_value
      - name: SPRING_PROPERTY2
        value: property_value
      - name: SPRING_0_PROPERTY
        value: property_value
</code></pre>
