Im building a docker image from maven using io.fabric8:docker-maven-plugin.
i want the container to run like :
java -jar -Dspring.profiles.active=prod /maven/myapp-1.4.3.jar
java -jar -Dspring.profiles.active=dev /maven/myapp-1.4.3.jar
so i actually want the image to pass -Dspring.profiles.active=$SPRING_PROFILES_ACTIVE and that variable will be passed in via docker run when starting a container:
docker run --env SPRING_PROFILES_ACTIVE=prod
however, it looks like the container run this command:
java -jar -Dspring.profiles.active=$SPRING_PROFILES_ACTIVE /maven/myapp-1.4.3.jar
and the $SPRING_PROFILES_ACTIVE is not replaced with the env var.
pom.xml:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.31.0</version>
<extensions>true</extensions>
<configuration>
<verbose>true</verbose>
<images>
<image>
<name>${docker.registry}/${project.artifactId}</name>
<build>
<from>java:8-jdk-alpine</from>
<tags>
<tag>${project.version}</tag>
<tag>latest</tag>
</tags>
<entryPoint>
<exec>
<args>java</args>
<args>-jar</args>
<!--<args>-Dspring.profiles.active=$SPRING_PROFILES_ACTIVE</args>-->
<args>/maven/${project.artifactId}-${project.version}.jar</args>
</exec>
</entryPoint>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
</build>
</image>
</images>