title: Multiple RUN instructions vs. single CMD to execute setup script in Dockerfile to initialize container
body: <p>What the is best practice for using many RUN commands in a Dockerfile to setup the image vs. a single CMD instruction to execute a script when the container starts?</p>
  
  <p>For example:</p>
  
  <pre><code>FROM  centos:latest
  
  RUN useradd myuser
  RUN mkdir -p /usr/local/myapp
  ADD ./resources/myapp.zip /usr/local/myapp
  RUN unzip /usr/local/myapp/myapp.zip
  RUN chown -R myuser:myuser /usr/local/myapp
  
  CMD ["/usr/local/myapp/bin/app"]
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>FROM  centos:latest
  
  ADD ./resources/myapp.zip /
  ADD ./resources/setup.sh / 
  RUN chmod +x /setup.sh
  
  # setup.sh will create the user, extract the zip, execute the binary
  CMD ["/setup.sh"]
  </code></pre>