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.

  • How to setup a MongoDB with Vagrant and Docker
  • Running VNCserver on docker container
  • docker Container command '/hello' not found or does not exist after switching hard drive
  • What are the default tcp ports used by GridGain
  • Docker RUN does NOT persist files
  • My docker container was created with no name and no tag
  • Unable to connect to SQL Server Linux Docker container via SQL Server Management Studio
  • Docker take advantage of several base images
  • Can't access django media from container volume
  • Docker container not able to locate Zip packages?
  • Connect Docker Container port to server's apache port (odoo Container)
  • Docker Ubuntu build that includes 'apt-get update'
  • 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 | 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.