So I know you can pass Environment variables to a docker container using -e like:
docker run -it -e "var=var1" myDockerImage
But I need to pass a System Property to a docker container, because this is how I run my JAR:
java -Denvironment=dev -jar myjar.jar
So how can I pass a -D System property in Docker? Like:
docker run -it {INSERT Denvironment here} myDockerImage
Advertisement
Answer
Use the variable you passed into the container on the java command:
docker run -it -e "ENV=dev" myDockerImage java -Denvironment=$ENV -jar myjar.jar