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.

  • GitlabCI build failed, docker.sock: write: broken pipe
  • Access docker.sock from inside a container
  • - How to debug apps which aren't running?
  • Docker communication between two container with Java
  • Mount a Host Directory as a Data Volume in docker?
  • Fluentd capture stack traces from Docker
  • How to design Docker routing and database Layer?
  • Docker push already in progress
  • docker build with a template Dockerfile
  • docker swarm - etcd cluster is unavailable or misconfigured
  • docker: Couldn't connect to Docker daemon
  • How to start another bash in Dockerfile
  • 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.