- lxc/libcontainer/ :: execution
- namespaces :: isolation
- cgroups :: sharing
- unionfs :: layering
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]]
make an image: docker build -t amonks/imagename .
pull an image: docker pull amonks/imagename
static (you probably want this) (all files and code are contained in the image)
dynamic (container links to local code ((while you develop)) )
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!
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
let's use docker compose
!
http://docs.docker.com/compose
[or panamax if you don't like CLI]