How to change Ruby and Rails version for the Rails base Docker image?

Docker base image rails provides a full environment for Ruby on Rails. It pulls from the ruby upstream image. The rails base image specifies Ruby and Ruby on Rails versions.

What if we want to use different Ruby and Ruby on Rails versions?

  • How to serve Docker containers with Nginx if there are multiple sites on one host?
  • Can't connect to docker published port for tftp
  • Customize mongo docker raise an error when I try to create a new user for database
  • Docker-compose: close ports after SIGTERM
  • Best practice: Python development environment with docker for mac
  • How to connect to the database in Docker in my case?
  • Do we edit our Dockerfile in our project folder? Or, do we ssh into the machine, and install the ruby version we want and then build our own image?

    Further details:

    The rails base image documentation says that your doc file can simply be one line of code:

    FROM rails:onbuild
    

    This line of code pulls from the rails image on Docker Hub. This image has its own Dockerfile. The first line of this Dockerfile is FROM ruby:2.2.

    Just to restate the question, what is the best way to create a container based off of the rails image, with different Ruby and Ruby on Rails versions? If possible, some sample code might be helpful for understanding how to do this.

  • GO - Local import not working
  • Docker client not able to connect to docker host on VM on Windows 7
  • Why did my Docker Container did not work when the container UID is missing on the host?
  • Strange behavior when using Marathon Health Check with the command protocol and a container
  • External access to Node.JS app, within Docker container
  • intel pin with docker
  • One Solution collect form web for “How to change Ruby and Rails version for the Rails base Docker image?”

    I assume you want a docker image that is suiteable for plenty of rails apps.

    I do not know docker at all, but maybe ignore what Docker offers to you, and do it yourself:

    Create an image with all great ruby versions, maybe 1.9 and 2.3,
    but i think you should just stick with latest ruby.

    Use https://github.com/rbenv/rbenv to provide a ruby env

    Every Rails applications usually ships with a Gemfile.
    In production releases, the gem versions are locked in the Gemfile.lock file.

    In case the gems need an update, you will need to update the app code and then the gems with

    bundle install
    

    So i think it´s not possible to have a docker “one-fits-all” image for plenty of rails apps nicely.

    Something i do when installing productive rails apps is to install their gems in the app folder.

    bundle install --path vendor/bundle
    

    This puts the gem apps inside their vendor directory. I see no big chance here either to make update life easier.


    As i never tried docker, or even visited their website, my post might be useless (sry)
    I hope i understood your intentions, at least.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.