forked from clio/ten_years_rails
-
Notifications
You must be signed in to change notification settings - Fork 42
Docker Development Environment for Old Ruby Versions
Juan Vásquez edited this page Apr 28, 2026
·
1 revision
Testing against specific Ruby versions locally is essential for catching version-specific bugs. This guide explains how to use Docker to test next_rails against Ruby 2.3+ without installing multiple Ruby versions on your system.
Legacy Ruby versions (2.3, 2.4, 2.5) can be difficult to install and maintain locally. Version-specific syntax issues (like Ruby 2.3 block parameter parsing) only appear when testing on those versions. Docker solves this by providing isolated Ruby environments.
- Ensure you have Docker and docker compose installed
- Create
docker compose.ymlin the project root with the content below - Run
docker compose run ruby-2.3to get started
services:
ruby-2.3:
image: ruby:2.3
container_name: next_rails_ruby_2_3
working_dir: /app
volumes:
- .:/app
command: bash -c "gem install bundler:1.17.3 && bundle _1.17.3_ install && bash"
stdin_open: true
tty: true# Interactive shell on Ruby 2.3
docker compose run ruby-2.3
# Inside the container
bundle _1.17.3_ exec rspec ./spec/deprecation_tracker_spec.rbdocker compose run ruby-2.3 bash -c "bundle _1.17.3_ install --quiet && bundle _1.17.3_ exec rake"docker compose run ruby-2.3 bash -c "bundle _1.17.3_ install --quiet && bundle _1.17.3_ exec rspec ./spec/deprecation_tracker_spec.rb"docker compose run ruby-2.3
# Now you're in a container with Ruby 2.3
# You can run bundle, rspec, irb, etc.docker compose downThis removes the containers but keeps images for faster subsequent runs.
- Docker
- docker compose
See Docker documentation to install.