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?
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?
The rails base image documentation says that your doc file can simply be one line of code:
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
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.
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
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.