AboutBlogContact
DevOpsNovember 15, 2013 2 min read 19

Dockerizing Your Legacy Rails App: No More 'Works on My Machine' (2013)

AunimedaAunimeda
📋 Table of Contents

Dockerizing Your Legacy Rails App: No More 'Works on My Machine'

In 2013, we're all tired of the same problem. You have a Ruby on Rails application that requires a specific version of Ruby (1.9.3), a specific version of MySQL, and a handful of system libraries for gems like nokogiri or rmagick. A new developer joins the team and spends two days just trying to get the app running on their Mac.

The answer is Docker. It's still new (0.x versions!), but it's already changing how we think about deployment and development environments.

The Problem: Ruby Dependency Hell

Before Docker, we used rvm or rbenv for Ruby versions and bundler for gems. But what about the underlying system dependencies? If the system has the wrong version of libxml2, your gem installation will fail, and your app won't start.

The Solution: The Dockerfile

In 2013, a basic Dockerfile for a Rails app looks like this:

# We start with a base image that has Ruby 1.9.3
FROM ruby:1.9.3

# Install system dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs

# Create the app directory
RUN mkdir /myapp
WORKDIR /myapp

# Copy the Gemfile and Gemfile.lock
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock

# Install gems
RUN bundle install

# Copy the rest of the application
COPY . /myapp

# Expose the Rails port
EXPOSE 3000

# Start the server
CMD ["rails", "server", "-b", "0.0.0.0"]

Docker Compose (formerly 'fig')

In late 2013, we're also starting to use fig (which will soon become docker-compose). It allows us to define our entire stack—Rails app, MySQL database, and Redis—in a single file.

# fig.yml (2013 era)
db:
  image: mysql:5.5
  environment:
    MYSQL_ROOT_PASSWORD: password

web:
  build: .
  command: bundle exec rails s -p 3000 -b '0.0.0.0'
  volumes:
    - .:/myapp
  ports:
    - "3000:3000"
  links:
    - db

Why It's a Game Changer

  1. Isolation: The database and app are completely isolated from the host machine.
  2. Consistency: The environment is exactly the same in development, staging, and production.
  3. Fast Onboarding: A new developer just runs fig up and they are ready to code.

In 2013, if you're not looking at containerization, you're missing the future of DevOps. Docker is the bridge between developers and operations that we've been waiting for.

Read Also

Beyond Zero-Downtime: Mastering State Persistence in Distributed Deploymentsaunimeda
DevOps

Beyond Zero-Downtime: Mastering State Persistence in Distributed Deployments

Zero-downtime deployment was the goal in 2018. In 2026, the challenge is 'State Continuity.' We explore how to manage database migrations and persistent WebSocket connections without dropping a single user session.

Docker Multi-Stage Builds: Slimming Down Your Production Images (2019)aunimeda
DevOps

Docker Multi-Stage Builds: Slimming Down Your Production Images (2019)

Shipping a 1GB Node.js image is so 2017. In 2019, we use multi-stage builds to separate our build environment from our runtime environment, resulting in tiny, secure images.

The Rise of Containerization: Why We are Moving Our Production to Dockeraunimeda
DevOps

The Rise of Containerization: Why We are Moving Our Production to Docker

The 'it works on my machine' era is over. In 2018, we are standardizing our development and production environments using Docker to solve the environment parity problem once and for all.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

Get Consultation All articles