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 do I set resources allocated to a container using docker?
  • docker commit apache container to image brings trouble
  • docker-compose: using multiple Dockerfiles for multiple services
  • Docker compose, interpolation of the assigned port
  • Mongo daemon doesn't run by service mongod start
  • docker-compose setup doesn't allow container to connect to redis
  • Cannot write into ~/.m2 in docker maven container
  • How to run a Windows GUI application from a Windows VM on a Docker installed on windows?
  • symfony failed to open stream: No such file or directory
  • Staging and Production on Kubernetes
  • Ubuntu docker image doesn't contain any /dev/sdX block devices?
  • supervisor curl command failing with exit 56 error
  • 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.