How to prepare a new Ruby env in 3 minutes using Docker

less than 1 minute read

One or two weeks ago, I registered to the Paris Ruby Workshop Meetup and needed a Ruby env. I have been using Vagrant quite a lot to isolate my different dev envs from each other and from my main machine. As I’ve been digging more into Docker lately, I thought I’d simply use Docker and Docker Compose instead.

I turned out to be dead simple. All that is needed is a docker-compose.yml file to define the container, record the shared volume and set a bundle path inside it :

  image: ruby:2.3
  command: bash
  working_dir: /usr/src/app
    BUNDLE_PATH: 'vendor/bundle'
    - '.:/usr/src/app'

Without the custom bundle path, bundled gems would be installed elsewhere in the container, and lost at every restart.

To use the Rubybox, just type docker-compose run rubybox and you’ll get a shell from within your ruby machine, where you can do everything you want.

In fact, I found the thing so useful, that I created the Rubybox git repo to simplify cloning and reusing. I’ve already cloned it at least 3 times since then !

git clone
cd rubybox
docker-compose run rubybox

I usually write about 15 minutes worth of reading per month. I won't transfer your email. No Spam, unsubscribe whenever you want.

As a gift for subscribing, you'll receive an illustrated mini-ebook "How to start a team coding dojo"!

Leave a comment