$30 off During Our Annual Pro Sale. View Details »

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
Tweet

More Decks by Alexander Clark

Other Decks in Programming

Transcript

  1. Docker
    What It Is and Why You Should Care

    View Slide

  2. My Story

    View Slide

  3. What is Docker?
    Virtualization

    View Slide

  4. View Slide

  5. View Slide

  6. =
    Virtual Machines
    Guest
    Host

    View Slide

  7. =
    Docker Containers

    View Slide

  8. That’s all great.
    Why should I care?

    View Slide

  9. • 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

    View Slide

  10. • 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.

    View Slide

  11. View Slide

  12. • Install Docker
    • Clone your Git repos
    • Place your docker-compose.yml file

    View Slide

  13. • docker-compose up

    View Slide

  14. =
    Dev Dev

    View Slide

  15. =
    Dev CI

    View Slide


  16. Dev Prod

    View Slide

  17. Where do I start?

    View Slide

  18. Background:
    Building Blocks

    View Slide

  19. Background
    Tools

    View Slide

  20. • Dockerfile
    • docker-compose.yml

    View Slide

  21. Docker Engine - Dockerfile

    View Slide

  22. 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

    View Slide

  23. Docker Compose YAML

    View Slide

  24. app:
    build: .
    command: rails server --port 3000 --binding 0.0.0.0
    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

    View Slide

  25. sidekiq:
    build: .
    command: bundle exec sidekiq
    environment:
    REDIS_URL: redis://redis:6379
    links:
    - db
    - redis
    volumes:
    - .:/var/www/myapp
    redis:
    image: redis

    View Slide

  26. Dockerfile
    docker-compose.yml

    View Slide

  27. Other Ways To Get Started

    View Slide

  28. View Slide

  29. Takeaways
    • Docker reduces dev dependencies
    • It adds parity where it is used (Dev-CI-Production)
    • Easy to get started

    View Slide

  30. Questions?

    View Slide

  31. • Alexander Clark
    • Twitter @atheclark
    • Blog http://alexander-clark.com/blog
    • Github alexander-clark
    • Slack alexander-clark

    View Slide

  32. Thanks for listening.

    View Slide