Docker Spring active profile

Viewed 51

i'm trying to set the active profile of my spring boot application, which runs in a docker container. The docker container is created using the gradle jib plugin.

According to stackoverflow posts, that I have found it is possible to set the active profile with: -e "SPRING_PROFILES_ACTIVE=test" or with -e "spring.profiles.active=test, but both options do not work for me. I always get the output: No active profile set, falling back to 1 default profile: "default".

Does somebody have an idea, why it does not apply the active profile?

My current docker command:

docker run -p 8888:8080 ...(the docker image)... \
      -e "SPRING_PROFILES_ACTIVE=test" \
      -e "spring.profiles.active=test" \
      -e "...additional spring environments..."

I sadly do not have a dockerfile, but this are the envs and the entrypoint from docker inspect:

"Env": [ "PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
         "LANGUAGE=en_US:en",
         "LC_ALL=en_US.UTF-8",
         "JAVA_HOME=/opt/java/openjdk",
         "JAVA_VERSION=jdk-11.0.16.1+1",
         "LANG=en_US.UTF-8"
       ],
"Entrypoint": [
        "java",
        "-cp",
        "@/app/jib-classpath-file",
        "my.organization.MyApplication"
 ],

1 Answers

Try with spring-boot.run.profiles.

As mentioned here and here.

Related