Get rid of the ARG
thing, as it's not needed and you aren't using it correctly anyway. Per the documentation:
The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command
So ARG
is a build-time thing, and you are trying to use it as a run-time environment variable.
Also, you can get rid of the "-Dspring.profiles.active=${ENV}"
part of your ENTRYPOINT
because Spring Boot already looks for an environment variable named SPRING_PROFILES_ACTIVE
so there's no need to define another thing here, and you're also introducing an issue with the way you are trying to resolve the ENV
variable here.
FROM openjdk:11-jdk
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]
Then run it with:
docker run -e SPRING_PROFILES_ACTIVE=test -p 8100:8080 anupbiswas1984/docker-env