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

GOTO Night Chicago -- Containerizing your Dev Environment

GOTO Night Chicago -- Containerizing your Dev Environment

Docker is a powerful platform for building and managing applications that is rapidly gaining momentum on development teams of all sizes. Even if you don't work in devops, if your application is deployed with Docker, you'll likely need to change up your development workflow. The good news is that Docker is a great tool for creating standardized environments -- whether you're on the back-end or the front-end. Although 'dockerizing' your workflow can feel daunting, you'll learn what Docker is, understand why development teams are adopting it, and walk away with what you need to quickly set up your own development environment and get to work.

Laura Frank

April 14, 2015
Tweet

More Decks by Laura Frank

Other Decks in Technology

Transcript

  1. GOTO Chicago returns in 2015
 Conference: May 11-12 / Workshops

    May 13-14
 New Location: The Westin River North www.gotocon.com/chicago-2015/
 Chad Fowler, Keynote Speaker, CTO at 6Wunderkinder Todd Montgomery, Keynote Speaker, Chief Architect at Kaazing Anita Sengupta, Keynote Speaker, NASA Jet Propulsion Lab Martin Thompson, Keynote Speaker, High Performance Computing Specialist Kyle Kingsbury, Keynote Speaker, Author of Jepsen Use promo code “DonClip100” for $100 off registration “I<3GOTO”
  2. Containerization: What is it? Working with Docker on a project

    Docker ecosystem nuts and bolts Stuff I WILL talk about
  3. A tool for managing containers • Managing code that goes

    in them • Executing code inside of them
  4. • Run in a self-contained execution environment • Share the

    kernel of host system • Are isolated from other containers • Have fast boot times & low overhead Containers
  5. A container is a virtualization layer — sort of like

    a VM — but with some fundamental differences
  6. hardware host OS hypervisor $ guest OS libraries web $

    guest OS $ guest OS libraries DB libraries web
  7. Containers have slightly more complexity but They reduce the amount

    of time/space resources needed to run your application
  8. • It’s fast! • It’s cheap! • It’s portable! •

    It’s safe! Benefits of Containerization
  9. A tool for managing containers • Managing code that goes

    in them • Executing code inside of them
  10. Interacting with the Registry • Push, pull, commit — similar

    to git • Two types of images • Services • Project base images
  11. Private Registries • Get setup image from Docker Registry •

    Can have authentication • Same interactions as public registry
  12. A tool for managing containers • Managing code that goes

    in them • Executing code inside of them
  13. • docker run my_image • docker stop container • docker

    attach container • docker ps -a Docker CLI
  14. • Has RESTful tendencies • Using CLI == using API,

    just abstracted • You could build your own tooling Docker API
  15. Objectives • Put code in container • Run the code

    inside the container • See application in web browser
  16. • A computer* • Code to run • Coffee (if

    you’d like) Things you need Installing Docker
  17. Anything else? You need to use a lightweight VM. Pro

    Tip: Boot2Docker (OSX and Windows) Linux? Install Docker with official packages. A Computer
  18. • Linked folders • Copied/added files • Port forwarding Handling

    Abstraction Code may seem out of reach, but can be managed or accessed using
  19. An image is controlled by a Dockerfile docker build -t

    foo/bar . docker pull foo/bar Code to Run All containers are based on images
  20. Code to Run • Packaged: all files and code are

    contained in image • Project: link folders to actively modify code (development only)* Two basic types of images:
  21. FROM centurylink/ruby-base:2.1.2 MAINTAINER Laura Frank <[email protected]> EXPOSE 4567 RUN mkdir

    -p /usr/src/app COPY . /usr/src/app WORKDIR /usr/src/app RUN bundle install CMD ruby hello_world.rb Dockerfile
  22. FROM centurylink/ruby-base:2.1.2 MAINTAINER Laura Frank <[email protected]> EXPOSE 4567 RUN mkdir

    -p /usr/src/app COPY . /usr/src/app WORKDIR /usr/src/app RUN bundle install CMD ruby hello_world.rb Dockerfile
  23. FROM centurylink/ruby-base:2.1.2 MAINTAINER Laura Frank <[email protected]> EXPOSE 4567 RUN mkdir

    -p /usr/src/app COPY . /usr/src/app WORKDIR /usr/src/app RUN bundle install CMD ruby hello_world.rb Dockerfile This copies code into the container STATIC! Not for apps under active development Great for dependencies and production applications
  24. FROM centurylink/ruby-base:2.1.2 MAINTAINER Laura Frank <[email protected]> EXPOSE 4567 RUN mkdir

    -p /usr/src/app COPY . /usr/src/app WORKDIR /usr/src/app RUN bundle install CMD ruby hello_world.rb Dockerfile Set a working directory and execute within
  25. FROM centurylink/ruby-base:2.1.2 MAINTAINER Laura Frank <[email protected]> EXPOSE 4567 RUN mkdir

    -p /usr/src/app COPY . /usr/src/app WORKDIR /usr/src/app RUN bundle install CMD ruby hello_world.rb Dockerfile This makes the code happen
  26. FROM centurylink/ruby-base:2.1.2 No need for version management, just use a

    different base image. Base images are great! Dockerfile
  27. • Available on Docker Hub • Maintained by other people

    (laziness++) • Repositories includes instructions for bootstrapping • Images can be base images or actually run services Official Images
  28. The Easy Way: Boot2Docker • Creates folder links for you

    • Obscures the separation between VM and host • Super handy for quick, small projects • Not great for more complex systems
  29. The Hard Way: Vagrant • Manually create folder links •

    Choose your own OS • Must ssh into VM • Great for more customization
  30. Either Way • Remember to forward ports in order to

    access app in a browser -p host_port:container_port
  31. Application Templating • Use your own images, or images from

    the Docker Registry • Specify config options beforehand (like port forwarding) • Run applications with one or two simple commands
  32. Docker workflow tool Itself a containerized application panamax.io Uses CoreOS,

    Fleet, and etcd for orchestration and service discovery
  33. --- name: Rails with PostgreSQL description: Rails with PostgreSQL images:

    - category: Web Tier name: Rails source: rheinwein/rails:latest description: Rails App type: Default expose: [] ports: - host_port: '8080' container_port: '3000' links: - service: Database alias: DB_1 environment: [] volumes: []