Skip to content

Instantly share code, notes, and snippets.

@amonks
Created April 8, 2015 23:41
Show Gist options
  • Save amonks/15eb6acdf950f5faf494 to your computer and use it in GitHub Desktop.
Save amonks/15eb6acdf950f5faf494 to your computer and use it in GitHub Desktop.
notes from laura frank's presentation on Docker at chicagoruby

docker

layers

  • lxc/libcontainer/ :: execution
  • namespaces :: isolation
  • cgroups :: sharing
  • unionfs :: layering

notes

docker replaces the hypervisor and os layers in a traditional vm setup

libraries can be shared between contained apps

so, it's a bit more complicated but also a bit more DRY

docker == engine + hub

the hub is where docker images live (within the docker registry) an image turns into a container; a container is an instance of an image

there are many canned docker images (you can also run your own registry( there's an image in the main registry))

boot2docker: have one vm on your mac running many containers [[also kitematic]]

images

make an image: docker build -t amonks/imagename .

pull an image: docker pull amonks/imagename

two types of image:

static (you probably want this) (all files and code are contained in the image)

dynamic (container links to local code ((while you develop)) )

an image is specified by Dockerfile

FROM centurylink/ruby-base:2.1.2       # base image to inherit from?

MAINTAINER Andrew Monks <[email protected]>

EXPOSE 4567                 # which port? [[we still need to bind with `docker run -p 80:4567` or whatever]]
# BIND 8080:4567              # we can also bind right from here

# ENV KEY value               # set an env variable [xcept rly don't]
                              # instead, `docker run -e "KEY=value`

# VOLUME "/var/foo"           # mount a volume

RUN mkdir -p /usr/src/app
ADD . /usr/src/app          # copy `./*` into the container

WORKDIR /usr/src/app        # set the working directory to that folder in the container

RUN bundle install          # aaaaand start ur engines normally
CMD "ruby hello_world.rb"

Instead of using a gemset and version management per service, configure that stuff in your base image! then re-use it between ur services!

no more gemsets! no more rvm! wow!

but what if we want to run it editably?

let's use a dynamic image!

docker run -it -p 8080:4567 -v ~/local/src/to/mount:/var/app centurylink/ruby-base:2.1.2 /bin/bash
           ^ interactive    ^ volume                         ^ base image                ^ open a prompt

but what if we wan't to run a whole bunch of containers and running docker run lots is a pain?

let's use docker compose!

http://docs.docker.com/compose

[or panamax if you don't like CLI]

http://panamax.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment