title: Passing active Spring profile to AWS ECS Task Container with Command option
body: <p>I am using AWS CodeBuild to build my Spring Boot application as Docker image and store it in Elastic Container Registry. Following is the excerpt from my Dockerfile</p>
  <pre><code>#run the app
  ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;]
  </code></pre>
  <p>The build stage is working fine and I get a Docker image created in ECR. I want to use this same Docker image for <code>staging</code> and <code>production</code> environment. And in order to do that, I have to set the right spring profile when the Docker container is started. I have tried passing the spring profile through <code>Command</code> option in ECS Task Container like below but no luck.</p>
  <blockquote>
  <p>-Dspring.profiles.active=test</p>
  </blockquote>
  <blockquote>
  <p>-Dspring.profiles.active,test</p>
  </blockquote>
  <blockquote>
  <p>&quot;-Dspring.profiles.active=test&quot;</p>
  </blockquote>
  <p>I know this can be done in <code>ENTRYPOINT</code> command but I need to do it dynamically when the container starts. Can anyone guide what is the right way to pass spring profile to ECS Task Container</p>