Ruby is a dynamic, reflective, object-oriented, general-purpose, open-source programming language.
5.1K
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/boxcutter/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/boxcutter/ruby:3.1-slim-noble
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/boxcutter/ruby:3.1-slim-noble your-daemon-or-script.rb
Containerfile in your Ruby app projectFROM docker.io/boxcutter/ruby:3.1-slim-noble
# 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
Gemfile.lockThe 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/boxcutter/ruby:3.1-slim-noble bundle install
Content type
Image
Digest
sha256:500a34bbf…
Size
69.5 MB
Last updated
over 1 year ago
docker pull boxcutter/ruby:3.4-slim-noble