Ruby is a dynamic, reflective, object-oriented, general-purpose, open-source programming language.
This image packages releases from https://github.com/docker-library/ruby
Image source: https://github.com/polymathrobotics/oci/tree/main/ruby
The Ruby REPL is called irb and is the default command running in this image:
docker run -it --rm \
docker.io/polymathrobotics/ruby:3.1-slim-jammy
For many simple, single file projects, you can run a Ruby script by using the container image directly:
docker run -it --rm \
--name my-running-script \
--mount type=bind,source="$(pwd)",target=/usr/src/myapp \
--workdir /usr/src/myapp \
docker.io/polymathrobotics/ruby:3.1-slim-jammy your-daemon-or-script.rb
FROM docker.io/polymathrobotics/ruby:3.1-slim-jammy
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /usr/src/app
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .
CMD ["./your-daemon-or-script.rb"]
Put this file in the root of your app, next to your Gemfile.
You can then build and run the Ruby image:
$ docker build -f Containerfile -t my-ruby-app .
$ docker run -it --name my-running-script my-ruby-app
The above example Containerfile expects a Gemfile.lock in your app directory. This docker run will help you generate one. Run it in the root of your app, next to the Gemfile:
$ docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app docker.io/polymathrobotics/ruby:3.1-slim-jammy bundle install