<p>Before start explaining my issue, it's worth mentioning that although I am trying to work how to use Maven Jib plugin in conjunction with Spring Boot and Kubernetes, the issue is the same even if I try to use a normal docker.</p>

<p>I have used Kubernetes configMap to create the application.yml file and mount it as an external file to the Pod (<code>/config/application.yml</code>). The issue I have been facing is my application does not able to find the <code>application.yml</code> file and throw a typical exception:</p>

<pre><code>ERROR [main] org.springframework.boot.SpringApplication: Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.Application]; nested exception is java.io.FileNotFoundException: class path resource [application.yml] cannot be opened because it does not exist
</code></pre>

<p>I have tried different approaches with Jib by using different arguments such as below.</p>

<pre><code>  &lt;container&gt;
    &lt;extraClasspath&gt;/config/*&lt;/extraClasspath&gt;
    &lt;args&gt;
      &lt;arg&gt;--spring.config.location=file:/config/application.yml&lt;/arg&gt;
    &lt;/args&gt;
    &lt;jvmFlags&gt;
      &lt;jvmFlag&gt;-Dspring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/config/&lt;/jvmFlag&gt;
    &lt;/jvmFlags&gt;
  &lt;/container&gt;
</code></pre>

<p>None of them has worked for me. I have also tried to use the <code>SPRING_CONFIG_NAME</code> environment variable and set it to <code>file:/config/application.yml</code> for the pod, but still the same issue.</p>

<p>I can verify that the config file exists in the specified location and there are no permission issues (as far as I can tell).</p>

<p>Interestingly, when I create just an empty <code>application.yml</code> file in the default classpath <code>(src/main/resources)</code> then it passes the first verification and the application loads successfully (with using the actual values from <code>/config/application</code>), so whatever the issue is it is being impacted by an initial verification of Spring Boot before even passing the application file to the corresponding classes.</p>

<p>It turns out that the only item I need to have is the following:</p>

<pre><code>&lt;container&gt;
    &lt;extraClasspath&gt;/config&lt;/extraClasspath&gt; &lt;!-- No need to have * at the end --&gt;
&lt;/container&gt;
</code></pre>
