title: Register environment variables in Dockerfiles dynamically
body: <p><strong>Problem</strong><br />
  Inside a Dockerfile, I want to do something like this:</p>
  <pre><code>ENV CONTAINER_INFO_GCC=\&quot;$(gcc --version | head -n 1)\&quot;
  </code></pre>
  <p>In a perfect world, at build time, this would produce this environment variable:</p>
  <pre><code>CONTAINER_INFO_GCC=&quot;gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609&quot;
  </code></pre>
  <p><strong>Motivation</strong></p>
  <p>I want to see what is installed in my docker container with the Azure DevOps system capabilities windows.</p>
  <p>For example, if I want to know which version of <code>gcc</code> is installed in my build environment, I can just take a look here:
  <a href="https://i.stack.imgur.com/zFjs4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zFjs4.png" alt="enter image description here" /></a></p>
  <p><strong>Question</strong><br />
  I have tried doing something like this, without the desired effect.</p>
  <pre><code>RUN echo CONTAINER_INFO_GCC=\&quot;$(gcc --version | head -n 1)\&quot; &gt;&gt; /etc/environment
  </code></pre>
  <p>Is there a way to use the Dockerfile <code>ENV</code> command dynamically?</p>