title: Use environment variables in docker
body: <p>I have implemented docker project for automated setup. I use docker 1.9 on Ubuntu Server and utilize feature <code>build-arg</code>. I using it for set dynamic subdomain in apache virtual hosts file. </p>
  
  <pre><code> docker build --no-cache --build-arg domain=demo1.myapp.com -t imagename .
   docker run -d -p 8080:80 imagename
  </code></pre>
  
  <p>I use domain and replace it in virtual hosts file using sed command in my script file</p>
  
  <pre><code>sed -i -e "s/defaulthost.com/$domain/g" /etc/apache2/sites-enabled/myApp.conf
  </code></pre>
  
  <p>My Dockerfile had code </p>
  
  <pre><code>ARG domain 
  RUN /bin/sh /script.sh $domain
  </code></pre>
  
  <p>Now I need to migrate application on AWS where I get Amazon Linux AMI. But here I get supported docker version 1.7, which do not support <code>build-arg</code>. I tried to upgrade but lot of dependencies block me.  </p>
  
  <p>Now I decide to use ENV environment variables like below.</p>
  
  <pre><code>docker run -d -p 8080:80 -e domain=demo1.myapp.com 
  </code></pre>
  
  <p>I also changed Docker file like</p>
  
  <p>My Dockerfile had code </p>
  
  <pre><code>RUN /bin/sh /script.sh
  </code></pre>
  
  <p>But It look like they not working in my scenario as at build time sed script replace empty value in apache file and build process failed. </p>
  
  <p>If it is not possible without build arg or I am doing wrong way of set/use ENV</p>