title: Passing docker runtime environment variables in docker image
body: <p>Here's my docker image. I want to override the default environment variables being set below from whatever is passed in the docker run command mentioned in the end</p>
  
  <pre><code>FROM ubuntu:16.04
  
  ADD http://www.nic.funet.fi/pub/mirrors/apache.org/tomcat/tomcat-8/v8.0.48/bin/apache-tomcat-8.0.48.tar.gz /usr/local/
  RUN cd /usr/local &amp;&amp; tar -zxvf apache-tomcat-8.0.48.tar.gz &amp;&amp; rm apache-tomcat-8.0.48.tar.gz
  RUN mv /usr/local/apache-tomcat-8.0.48 /usr/local/tomcat
  RUN rm -rf /usr/local/tomcat/webapps/*
  
  ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
  ENV CATALINA_HOME /usr/local/tomcat
  ENV CATALINA_BASE /usr/local/tomcat
  ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
  
  ENV dummy_url defaulturl
  ENV database databasedefault
  
  COPY my.war /usr/local/tomcat/webapps/
  
  RUN echo &gt;&gt; /usr/local/tomcat/conf/test.properties
  RUN echo dummy_url =$dummy_url &gt;&gt; /usr/local/tomcat/conf/test.properties
  RUN echo database =$database &gt;&gt; /usr/local/tomcat/conf/test.properties
  
  ENTRYPOINT ["catalina.sh", "run"]
  </code></pre>
  
  <p>To run in local :</p>
  
  <pre><code>docker run -p 8080:8080 -e dummy_url=http:google.com -e database=jdbc://mysql allimages/myimage:latest
  </code></pre>
  
  <p>dummy_url and database do not seem to be getting overridden in the file that I am adding them in - test.properties. Any ideas would be greatly appreciated.</p>