<p>I have the following in my Dockerfile to run my Springboot app:</p>

<pre><code>ENTRYPOINT [ "java", "-jar", "/code/myapp/target/myapp.jar", "--spring.profiles.active=$ENV_PROFILE"]
</code></pre>

<p>I defined my environment variable (ENV_PROFILE) in my k8 YAML config as:</p>

<pre><code> spec:
  containers:
    - name: myspringboot
      image: myrepo/myapp:latest
      imagePullPolicy: Always
      resources:
        requests:
          cpu: 100m
          memory: 100Mi
      env:
      - name: ENV_PROFILE
        value: "test"
</code></pre>

<p>However, the environment name is not getting injected into the java springboot app.  It shows as "$ENV_PROFILE" in the log.  I also tried with application.properties by adding <code>spring.profiles.active=$ENV_PROFILE</code>
and that does not work either.</p>

<p>You can also override the Spring properties (and other properties defined in the application properties) by default, without specifying what environment variable to pass in your properties file. Environment variables have higher precedence then the properties file values. </p>

<p>See also <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html" rel="noreferrer">Spring Externalized Configuration</a>.</p>

<p>For example:</p>

<pre><code> spec:
  containers:
    - name: myspringboot
      image: myrepo/myapp:latest
      imagePullPolicy: Always
      resources:
        requests:
          cpu: 100m
          memory: 100Mi
      env:
      - name: SPRING_PROFILES_ACTIVE
        value: "test"
</code></pre>
