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?

  • No public port '22/tcp' published for test_sshd
  • docker import data in mongodb successfull but nothing in database
  • Unsupported config option for services service: 'httpd'
  • How to direct logs from etsy statsd docker to stdout?
  • How to add external my.cnf file to Percona server in Docker?
  • cannot run jfrog executable from inside alpine linux container
  • 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.

  • How do I run nginx -t when nginx is running inside a docker container? [duplicate]
  • Docker error connecting to host mysql
  • Docker “Operation not permitted” issue on Windows
  • Access Jupyter notebook running on Docker container
  • Utilizing the --user param to create a user with a Dockerfile container
  • Upgrade docker on CentOS 7
  • 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.