A Docker image for Ruby, built with jemalloc.
The images are based on the official Ruby "slim" and official Ubuntu "22.04"/"24.04"/"26.04" (LTS) images on Docker Hub.
The following images are used:
ruby:${RUBY_VERSION}-slimubuntu:22.04ubuntu:24.04ubuntu:26.04
The following platforms are built:
linux/amd64linux/arm64
The following Ruby versions are built:
3.2.113.3.113.4.104.0.6
Images for Ruby >= 3.2.x are compiled with YJIT support.
Container images are available but no longer maintained for the following versions:
3.2.43.2.53.2.63.2.73.2.83.3.43.3.53.3.63.3.73.3.83.4.13.4.23.4.33.4.44.0.5
and the following platforms:
ubuntu-20.04
GitHub Actions is set up to gather the latest available Ruby versions with the ruby-versions-action and feed it to the build process. The plan is to run the build pipeline and update the REAMDE from a template regularly (e.g. weekly) in the future. For now this has to be done manually, so feel free to open a new issue once a new release needs to be supported (it usually takes a few minutes to trigger the pipeline and update the README).
The Dockerfile is set up in a way which makes it possible to compile pretty much any recent Ruby release from the index on the ruby-lang.org website. The only two build arguments you need to provide are RUBY_VERSION (e.g. 4.0.6) and the associated sha256 checksum as RUBY_CHECKSUM (e.g. 837d299e8f7ddf2be31a229a7a7e019d354979825117989acb3b32b1a9be262a) of the tar.gz package associated with the relevant version.
You can always use the ruby-version-checker container to fetch the latest available Ruby releases and their corresponding checksums:
$ docker run ghcr.io/moritzheiber/ruby-version-checker
# [...]
[
{
"name": "3.2.11",
"url": "https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.11.tar.gz",
"sha256": "b3eeabd6636f334531db3ffdc3229eb05e524740e6c84fdc043720573cf2f8b2"
},
{
"name": "3.3.11",
"url": "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.11.tar.gz",
"sha256": "59f0fafb1a59a05dc3765117af3fa68e153eb48254708549f321c1e9e078d7a0"
},
{
"name": "3.4.10",
"url": "https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.10.tar.gz",
"sha256": "ecee2d072a14f2d14347dd56dfd8fe5c3130abf5117bfaacbda0f4ef9cc429ec"
},
{
"name": "4.0.6",
"url": "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.6.tar.gz",
"sha256": "837d299e8f7ddf2be31a229a7a7e019d354979825117989acb3b32b1a9be262a"
}
]If you wish to pass additional compile-time options you can use the build argument ADDITIONAL_FLAGS (e.g. to enable YJIT support for Ruby >= 3.2.x):
$ docker build \
--build-arg RUBY_VERSION="4.0.6" \
--build-arg RUBY_CHECKSUM="837d299e8f7ddf2be31a229a7a7e019d354979825117989acb3b32b1a9be262a" \
--build-arg ADDITIONAL_FLAGS="--enable-yjit" \
-t ruby-jemalloc:4.0.6-slim .The Dockerfile uses the official Ruby slim image by default, but you can also use your own base image by passing the build argument IMAGE_NAME:
$ docker build \
--build-arg RUBY_VERSION=4.0.6 \
--build-arg RUBY_CHECKSUM=837d299e8f7ddf2be31a229a7a7e019d354979825117989acb3b32b1a9be262a \
--build-arg IMAGE_NAME=ubuntu:22.04 \
-t ruby-jemalloc:4.0.6-ubuntu-22.04 .Note: Ruby 4.0.6-slim is the default when building the Docker image without any build arguments.
The tests are run using goss:
dgoss run -ti ruby-jemallocYou can specify the Ruby version to test for by passing RUBY_VERSION as a variable:
dgoss run -ti -e RUBY_VERSION=4.0.6 ruby-jemallocNote: 4.0.6 is the default. And don't forget to also pass the correct RUBY_CHECKSUM.