Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker: What It Is and Why You Should Care

Docker: What It Is and Why You Should Care

A brief explanation of what Docker actually is and instructions for setting up a Rails dev environment in Docker.

Alexander Clark

July 26, 2016

More Decks by Alexander Clark

Other Decks in Programming


  1. • Install Homebrew • brew install several packages - SQL,

    Imagemagick • Install RVM or Rbenv • Install one or more versions of Ruby • Clone one or more Git repos • Run bundle/npm/bower/etc install for each repo
  2. • Start the db server (unless it’s always running) •

    Start the rails app • Background workers? Sidekiq and Redis • SoA? Need to start those up too on the right port • iTerm or Tmux setup to run all this? Foreman? • Foreman requires same directory. Subcontractor.
  3. FROM ruby:2.3.1-slim RUN apt-get update -qq && apt-get install -y

    \ build-essential libpq-dev postgresql-client ENV RAILS_ROOT /var/www/myapp RUN mkdir -p $RAILS_ROOT/tmp/pids WORKDIR $RAILS_ROOT COPY Gemfile Gemfile COPY Gemfile.lock Gemfile.lock RUN gem install bundler RUN bundle install
  4. app: build: . command: rails server --port 3000 --binding

    environment: RAILS_ENV: development DATABASE_HOST: db links: - db ports: - 3000:3000 volumes: - .:/var/www/myapp db: image: postgres:9.5.3 environment: POSTGRES_USER: username POSTGRES_PASSWORD: password volumes: - myapp-db:/var/lib/postgresql/data
  5. sidekiq: build: . command: bundle exec sidekiq environment: REDIS_URL: redis://redis:6379

    links: - db - redis volumes: - .:/var/www/myapp redis: image: redis
  6. Takeaways • Docker reduces dev dependencies • It adds parity

    where it is used (Dev-CI-Production) • Easy to get started