title: Dockerfile ENV variable substitution into another ENV variable
body: <p>I am learning Docker and facing issue in substituting the value of one env variable into another env variable.</p>
  
  <p>This is my Dockerfile</p>
  
  <pre><code>FROM ubuntu
  
  ENV var_env=Tarun
  
  ENV command="echo Hello $var_env"
  
  CMD ["sh","-c","echo Hello $var_env"]
  
  </code></pre>
  
  <p>Now, after building it with tag name "exp", then</p>
  
  <pre><code>sudo docker run -e  "var_env=New Env Value" exp
  </code></pre>
  
  <p>It gives me correct output as </p>
  
  <pre><code>Hello New Env Value
  </code></pre>
  
  <p>But, if I see the environment variables associated by executing </p>
  
  <pre><code>sudo docker run -e  "var_env=New Env Value" exp env
  </code></pre>
  
  <p>It gives me this output:</p>
  
  <pre><code>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  HOSTNAME=138aa8852d8d
  var_env=New Env Value
  command=echo Hello Tarun
  HOME=/root
  </code></pre>
  
  <p>In it, the value of <code>var_env</code> environment variable is changed and value of <code>command</code> environment variable remains same.</p>
  
  <p>I need to find a way so that if I change the value of <code>var_env</code> environment variable by the above command, it will update the value of <code>var_env</code> environment variable inside <code>command</code> environment variable also.</p>
  
  <p>For reference: <a href="https://docs.docker.com/engine/reference/builder/#environment-replacement" rel="noreferrer">https://docs.docker.com/engine/reference/builder/#environment-replacement</a></p>