title: ENV, RUN produce layers, images or containers? (understanding docs question)
body: <p>I've searched <code>site:stackoverflow.com dockerfile: ENV, RUN - layers or images</code> and have read <a href="https://stackoverflow.com/questions/41637560/does-docker-expose-make-a-new-layer">Does Docker EXPOSE make a new layer?</a> and <a href="https://stackoverflow.com/questions/31222377/what-are-docker-image-layers">What are Docker image &quot;layers&quot;?</a>.</p>
  
  <p>While reading docs <a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/" rel="nofollow noreferrer">Best practices for writing Dockerfiles</a> and trying to understand this part:</p>
  
  <blockquote>
    <p><strong>Each ENV line creates a new intermediate layer, just like RUN
    commands</strong>. This means that even if you unset the environment variable
    in a future layer, it still persists in this layer and its value can
    be dumped.</p>
  </blockquote>
  
  <p>I recalled that part above:</p>
  
  <blockquote>
    <p>In <strong>older versions</strong> of Docker, it was important that you minimized the
    number of layers in your images to ensure they were performant. The
    following features were added to reduce this limitation:</p>
    
    <p><strong>Only the instructions RUN, COPY, ADD create layers.</strong> Other instructions
    create temporary intermediate images, and do not increase the size of
    the build.</p>
  </blockquote>
  
  <p>I've read <a href="https://stackoverflow.com/questions/55789409/how-to-unset-env-in-dockerfile">How to unset &quot;ENV&quot; in dockerfile?</a>. and redid the example given on doc page, it indeed proves <code>ENV</code> is not unset:</p>
  
  <pre><code>$ docker build -t alpine:envtest -&lt;&lt;HITHERE
  &gt; FROM alpine
  &gt; ENV ADMIN_USER="mark"
  &gt; RUN unset ADMIN_USER
  &gt; HITHERE
  Sending build context to Docker daemon  3.072kB
  Step 1/3 : FROM alpine
  latest: Pulling from library/alpine
  89d9c30c1d48: Already exists 
  Digest: sha256:c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a
  Status: Downloaded newer image for alpine:latest
   ---&gt; 965ea09ff2eb
  Step 2/3 : ENV ADMIN_USER="mark"
   ---&gt; Running in 5d34f829a387
  Removing intermediate container 5d34f829a387
   ---&gt; e9c50b16c0e1
  Step 3/3 : RUN unset ADMIN_USER
   ---&gt; Running in dbcf57ca390d
  Removing intermediate container dbcf57ca390d
   ---&gt; 2cb4de2e0257
  Successfully built 2cb4de2e0257
  Successfully tagged alpine:envtest
  $ docker run --rm alpine:envtest sh -c 'echo $ADMIN_USER'
  mark
  </code></pre>
  
  <p>And the output says same "Removing <strong>intermediate container</strong>" for both <code>ENV</code> and <code>RUN</code>. 
  I've recently downloaded <code>docker</code>, don't think it is <em>that old</em>:</p>
  
  <pre><code>$ docker --version
  Docker version 19.03.5, build 633a0ea
  </code></pre>
  
  <p>Maybe <code>RUN instruction</code> and <code>RUN command</code> is a different thing?<br>
  <code>ENV</code>, <code>RUN</code> - do they create layers, images or containers?</p>