title: Bundle optimization for ruby on Docker
body: <p>I'm new to docker and was wondering how does ruby bundler behave when re-building docker images? The first time I build an image it takes forever to <code>bundle install</code>. What will happen when I add another gem into the Gemfile? Is there a way to ensure previous gems are cached somehow in the image and used for this  new bundling?</p>
  
  <p>Dockerfile:  </p>
  
  <pre><code>FROM rails:onbuild
  RUN apt-get install -y imagemagick
  </code></pre>