The smallest Docker image with Ruby, is based on Alpine Linux image, which is only a 5MB image. It does only include ruby and bundler gem.
This is minimal image with only necessary packages, to run your app in production. Image build by using only official applications from Alpine linux, and supported AS IS.
Tags referring Alpine ruby version, not ruby version.
Check ruby version:
docker run -ti --rm andrius/alpine-ruby:latest ruby -v
Hello, world:
docker run -ti --rm andrius/alpine-ruby ruby -e "puts 'Hello, world!'"
Once you have run this command you will get printed 'Hello World' from Ruby!
Sometimes you could need to install various gems, where development packages is mandatory.
Usually it's enough to install following packages:
apk add --update ruby-dev build-base \
libxml2-dev libxslt-dev pcre-dev libffi-dev \
mariadb-dev postgresql-dev
In order to install nokogiri, you could use alpine's version:
apk add --update ruby-nokogiri
However you could need specific version or want to follow version from Gemfile, you could install it:
# installing *dev stuff
apk add --update ruby-dev build-base
bundle install
# or you could install gem directly
gem install nokogiri -- --use-system-libraries
# removing *dev stuff
apk del ruby-dev build-base