ruby
Used to run apps built with the Ruby on Rails framework and for background job processing, automation scripts, and web APIs.
What is ruby?
The ruby image provides a containerized runtime for Ruby applications, including the Ruby interpreter, standard libraries, and tools like gem and bundler. Ruby is a dynamic, object-oriented language popular for its developer-friendly syntax and rich ecosystem of gems.
This image is commonly used to run applications built with the Ruby on Rails framework, as well as for background job processing (Sidekiq, Resque), automation scripts, and web APIs. Ruby is frequently deployed in containerized environments for SaaS platforms, e-commerce sites, and monolithic applications transitioning to Kubernetes or cloud-native infrastructure.
By packaging Ruby in a container, teams can ensure consistency across environments, pin dependencies, and streamline CI/CD pipelines. The ruby image is relevant to modern infrastructure because it bridges traditional web application development with containerized operations, making it easier to run legacy apps and new services side by side.
How to use this image
The ruby image can be used to run Ruby interactively, execute scripts, or serve as a base image for Rails and other frameworks. It supports volume mounting for development, but production images should bake dependencies into the build for reproducibility.
Run Ruby interactively:
<code>docker run -it ruby</code>
Run a script from your local machine:
<code>docker run --rm -v $(pwd):/app -w /app ruby ruby script.rb</code>
Build a custom image with Bundler:
<code>FROM ruby:3.3-slimWORKDIR /appCOPY Gemfile* ./RUN bundle installCOPY . .CMD ["ruby", "app.rb"]</code>
Logs and application output are written to stdout
and stderr
, accessible with docker logs
. By default, Ruby runs the specified script or command and the container exits upon completion.
{{cta}}
Image variants
Published under ruby, the image is available in multiple variants:
ruby:latest
Tracks the most recent stable Ruby release.Useful for testing, but not recommended in production due to version drift.
ruby:<version>
Tagged by release version (e.g. 3.3
, 3.2
).
Recommended for stable and reproducible environments.
ruby:<version>-slim
Smaller Debian-based image with reduced libraries and tools.A good balance between functionality and footprint.
ruby:<version>-alpine
Minimal Alpine-based image.Provides a very small base, though installing gems with native extensions may require additional build tools.Ruby images are regularly rebuilt to include upstream patches. For production workloads, pin to a specific version tag such as ruby:3.3.1-slim
.