How to install Ruby on docker?

I am trying to install ruby on docker. I could install the 1.9 versions but it is not possible to install the latest version such as 2.2.0 and above. I am actually trying to set up calabash on docker. Have tried this. Whenever I try to install calabash-android in it getting the error

ERROR:  Error installing calabash-android:
luffa requires Ruby version >= 2.0.

  • Docker - Can't access MySQL CLI in container
  • Why is this docker image allowed past the firewall?
  • Dynamically Pull Docker Image using chef recipe
  • Responses from kubernetes containers getting lost
  • Windows Docker in PyCharm - How to locate files on my host computer?
  • Share docker images between hosts with NFS
  • docker how to commit but exclude directory from image
  • How do you remove the contents of a docker volume?
  • docker build shows: failed sandbox add: failed to set gateway while updating gateway: invalid argument
  • pdf2htmlEX cannot open or read file
  • How to check whether python package is installed or not in Docker?
  • haproxy not routing to service
  • 2 Solutions collect form web for “How to install Ruby on docker?”

    You could start view a dockerfile starting with:

    FROM ruby:2.3.0
    

    That would use the docker image ruby, with ruby already installed.

    If you’re starting FROM a different base Docker instance, you can simply RUN commands that install Ruby from your base instance’s package management system. For example, this GitHub Gist shows how to use apt-get to install Ruby on a Ubuntu instance:

    # Pull base image.
    FROM dockerfile/ubuntu
    
    # Install Ruby.
    RUN \
      apt-get update && \
      apt-get install -y ruby
    

    And this Gist shows a Dockerfile that’s configured to install RVM and Ruby on a Ubuntu instance:

    FROM ubuntu
    
    RUN apt-get update
    
    # basics
    RUN apt-get install -y openssl
    
    # install RVM, Ruby, and Bundler
    RUN \curl -L https://get.rvm.io | bash -s stable
    RUN /bin/bash -l -c "rvm requirements"
    RUN /bin/bash -l -c "rvm install 2.0"
    RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.