title: Pass ENV variable with docker-compose.yml at runtime to Dockerfile
body: <p>I am trying to override the ENV values in my dockerfile depending on the environment (dev/uat/prod) from my docker-compose.yml.  Because some of the settings are sensitive I cant have these settings be apart of the build step of the docker image, instead these values must be overridden during runtime.  Ive been trying to deploy the following docker-compose via the docker stack deploy -c command, however i noticed my environment variables are not overriding the existing ones in the dockerfile.</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM openjdk:8-jdk-alpine
  VOLUME /tmp
  VOLUME /etc
  
  ADD sample-0.0.1-SNAPSHOT.jar app.jar
  
  ENV ENV_SETTINGS=ssldev
  ENV ZK_HOST=zoo1
  ENV JAVA_OPTS="-server -Xms6048m -Xmx6048m -XX:+UseParNewGC - XX:+UseConcMarkSweepGC -XX:+UseTLAB -XX:NewSize=128m -XX:MaxNewSize=128m - XX:MaxTenuringThreshold=0 -XX:SurvivorRatio=1024 - XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=40 - XX:MaxGCPauseMillis=1000 -XX:InitiatingHeapOccupancyPercent=50 - XX:+UseCompressedOops -XX:ParallelGCThreads=8 -XX:ConcGCThreads=8 - XX:+DisableExplicitGC -Dspring.profiles.active=${ENV_SETTINGS}"
  
  EXPOSE 8080
  ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
  HEALTHCHECK CMD curl --fail -k https://localhost:8080/status || exit 1
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: '3.1'
  
  services:
  api:
      image: SOME_RANDOM_IMAGE
      ports:
          - "9083:8080"
      networks:
          - net
      deploy:
          restart_policy:
              condition: on-failure
          mode: global
      environment:
          - ENV_SETTINGS: default,ssldev,postgres
          - ZK_HOST: zoo1:2181,zoo2:2181
  networks:
  nsp_net:
    external:
      name: net
  </code></pre>