How to Make Docker Images Smaller: Ruby and Rails Images

By richardtylee

As I stated earlier, we are primarily a Ruby on Rails organization.  As such, there are plenty of ruby and rails community-supported docker images available to used as base images.

We took a look at some of the ruby and rails images we use. All these images are debian based. Even amongst minor versions, we found large differences in size. In general (though not always the case), the latest minor version will be the smallest size. Since minor versions are backwards compatible, we should be on the latest minor version. It is a good idea to standardize the ruby and rails version we use for our services. Unless there's a specific reason to deviate, we should sit to one version for consistency.

Below is are some of the versions I was able to download and their sizes:

REPOSITORY              TAG                             VIRTUAL SIZE
ruby                    2.1.1                           1.556 GB
ruby                    2.1.2                           890.4 MB
ruby                    2.1.3                           803.8 MB
ruby                    2.1.7                           717.8 MB

REPOSITORY              TAG                             VIRTUAL SIZE
rails                   4.1.1                           1.036 GB
rails                   4.1.6                           839.1 MB
rails                   4.1.8                           919.4 MB
rails                   4.2.1                           884.6 MB
rails                   4.2.5                           825.2 MB

Because ruby is the base image of rails, we also have the option of starting with ruby and installing rails.