title: Does Docker build a base image everytime a "child" container is run?
body: <p>I am new to <code>docker</code> and the world of <code>containers</code>..Am using <code>Microsoft servercore</code> as my <code>base image</code>, and need an application installed on it, which I copy and install on the <code>image</code>, and copy some other files besides. I then build this image and use it as a <code>base image</code> for another container which works on these files.</p>
  
  <p>However, it takes a long time for the second <code>container</code> to start doing its job, which left me wondering if Docker containers build their base images from scratch everytime they are run. </p>
  
  <p>If this is the case, then is it possible for me to build a base image which comes installed with everything I need, so all the steps in the base image build (copying files, installing etc.) are not carried out everytime it is consumed by a "child" container?</p>
  
  <p>If it is not the case, is there a reason why the child container should start that late? 
  Some way to check which step is being executed by a container, perhaps?</p>
  
  <p><strong>UPDATE</strong> - I checked in a crude way, by removing one of the files which get copied into the base image, and by checking if it would create issues, but it didn't, so quite likely the base image container does not get built everytime it is consumed by a child container, but the time taken between Docker Run and the execution of a simple batch as the first step is quite high...</p>
  
  <p><strong>UPDATE 2</strong> - For more clarity...</p>
  
  <p><strong>DockerFile 1</strong> (builds as testdocker)</p>
  
  <pre><code>FROM mcr.microsoft.com/windows/servercore  
  ADD 7z1900-x64.exe /7z1900-x64.exe  
  RUN powershell.exe -Command Start-Process .\7z1900-x64.exe -ArgumentList '/S /D=c:/' -Wait
  </code></pre>
  
  <p><strong>Dockerfile 2</strong></p>
  
  <pre><code>FROM testdocker
  COPY testbat.bat /testbat.bat
  CMD testbat.bat &amp;&amp; cmd
  </code></pre>
  
  <p><strong>Batch file executed in second container</strong></p>
  
  <pre><code>@ECHO ON
  dir
  pause
  </code></pre>