Search⌘ K
AI Features

The Image Build Cache

Explore how Docker's image build cache works to speed up your Rails application development. Understand when cache gets invalidated and how to structure your Dockerfile to minimize rebuilds, making your development cycle more efficient.

Image build cache

During development, we rebuild our image fairly regularly, either to install new gems (bundle install is one of the steps in our Dockerfile) or to update our dependencies such as Node.js.

A fast test suite helps by reducing the feedback loop. Similarly, it is important to keep our image builds as fast as possible too. One way that Docker helps achieve this is by caching each step in our build. This means that it only needs to rebuild from the first instruction in the Dockerfile where there is a change. A change could either be literally ...