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

Introduction to Docker

John Downey
February 06, 2014

Introduction to Docker

Given at the first Chicago Docker meetup

John Downey

February 06, 2014
Tweet

More Decks by John Downey

Other Decks in Programming

Transcript

  1. Laptop CI QA Staging Prod Rails code ? ? ?

    ? ? PostgreSQL ? ? ? ? ? RabbitMQ ? ? ? ? ? libxyz ? ? ? ? ?
  2. LXC: LINUX CONTAINERS • Linux host (kernel >= 2.6.29) •

    Linux container (guest) • Must match host architecture • No need to match kernel/distro
  3. DOCKER • Builds on LXC • Server (host) mode requires

    Linux and LXC • Recommend kernel >= 3.8 • Client mode runs almost anywhere (Linux/OS X)
  4. WHAT DOCKER ADDS • Images • Layers • Tags •

    Repository • Create and share images
  5. DOCKER COMMAND • Written in Go • Open source •

    Manages containers and images • Provides HTTP API • Built in CLI client uses API
  6. ADVANTAGES OVER A VM • Package a run-time environment •

    Runnable on any linux host • Keeps things isolated and ephemeral • Fast and simple
  7. IMAGES VS CONTAINERS • Images are a template • File

    system • Metadata (ports to expose, command to run) • Containers are what is running
  8. IMAGE LAYERS • Images are built up from layers •

    Each layer is read-only filesystem • Top layer is a new read-write layer
  9. IMAGE HIERARCHY • Form a directed tree • Each image

    can specify a parent image • Starts with the parents layers below its own
  10. WAYS TO MAKE IMAGES • Commit a running container (docker

    commit) • Dockerfile (docker build) • Import a tarball (docker import)
  11. DOCKERFILE • FROM - What my parent image is •

    RUN - Perform a command to prepare the image • ADD - Add a file to the image • EXPOSE - Allow access to a specified port • ENV - Set an environment variable • CMD - Default command to run on container creation
  12. FROM wheezy-base ! ENV DEBIAN_FRONTEND noninteractive ! RUN apt-get install

    -y ruby1.9.1 ruby1.9.1-dev RUN apt-get install -y build-essential RUN apt-get install -y libpq-dev RUN apt-get install -y libxml2-dev libxslt-dev RUN apt-get install -y libcurl4-openssl-dev RUN gem install bundler ! EXPOSE 3000 ! WORKDIR /gateway ADD . /gateway/ RUN bundle install ! CMD ["bundle", "exec", "rails", "server", "thin"]