What would be a quick way to run a ruby script that needs a few gems within a docker container?
I often come across the situation where I want to try out a new gem, or write a short script, and I don't want to install the gem locally. My first idea was to write a Dockerfile and build the image, e.g.
FROM ruby:latest
RUN gem install httparty
COPY test.rb /usr/app/
CMD ["ruby", "/usr/app/test.rb"]
and test.rb
require "httparty"
puts HTTParty.get("https://now.httpbin.org/").body
Then run docker build -t run-ruby-with-gems . and after the build docker run -it --rm run-ruby-with-gems
This works, but isn't handy. So maybe there is some smart one liner or anything else that could make the whole process of quickly running a ruby script easier.