title: Passing env variables to DOCKER Spring Boot
body: <p>I have a SpringBoot application and its Dockerfile is as follows. I have application.properties for different environments like local/dev/qa/prod. When I run the application locally in IDE, I pass <strong>-Dspring.profiles.active=local</strong> in VM options so that it loads the application-local.properties. For running as docker containers, I build an image which comprises of all the application.properties. i.e. it's only SAME docker image for all the environments. </p>
  
  <p>When I run the image in an environment, I want to somehow make the SpringBoot to understand that its dev env, so it has to load application-dev.properties. I am using AWS ECS for managing the containers. </p>
  
  <pre><code>FROM openjdk:8-jdk-alpine
  VOLUME /tmp
  ADD target/sample-test-sb-sample-app-1.0-exec.jar app.jar
  EXPOSE 8080
  ENV JAVA_OPTS=""
  ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
  </code></pre>