title: Docker RUN Command
body: <p>I'm confused about this following passage in the <a href="http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/" rel="nofollow">article</a> about Docker's <code>CMD</code> vs. <code>RUN</code> vs. <code>ENTRYPOINT</code>.</p>
  
  <blockquote>
    <p>Note that <code>apt-get update</code> and <code>apt-get install</code> are executed in a single RUN instruction. This is done to make sure that the latest packages will be installed. If <code>apt-get install</code> were in a separate RUN instruction, then it would reuse a layer added by <code>apt-get update</code>, which could had been created a long time ago.</p>
  </blockquote>
  
  <p>The code given for the passage is:</p>
  
  <pre><code>RUN apt-get update &amp;&amp; apt-get install -y \  
    bzr \
    cvs \
    git \
    mercurial \
    subversion
  </code></pre>
  
  <p>I really don't understand their explanation for putting <code>apt-get install</code> on the same line. Wouldn't <code>apt-get update</code> complete, and then <code>apt-get install...</code> would proceed if they were on separate lines? The article makes it sound like <code>apt-get install...</code> wouldn't see any of the effects that <code>apt-get update</code> made if on separate lines.</p>