5. ● Emulate hardware (or a complete system)
○ Useful to:
■ work with a diferent hardware+software
■ work with several virtual machines in one machine
● Some hypervisors: VirtualBox (2007), VMWare (1998)
● Based in a “image” of the whole system
Docker
Virtualization
6. ● Images are too big to be portable
● Solution: Vagrant (2010)
○ Based on boxes
○ Uses a recipe (Vagrantfile) to install extra software, alter
configurations, etc (a.k.a “provisioning”)
○ Just share the recipe!
Docker
Virtualization problems
7. ● Virtual machines take too long to start
○ Keep them on
● What if… we use the (already started) Linux kernel?
Docker
Virtualization problems
8. ● Docker (2013): allows independent "containers" to run within a
single Linux instance (share kernel libraries)
● Docker container
○ piece of software in a complete filesystem that contains
everything it needs to run: code, runtime, system tools,
system libraries
Docker
Docker to the rescue!
9. ● Make single-task containers
● Deploy as you need (servers or cloud)
Docker
Docker
11. ● The recipe!
○ Based on public images hub.docker.com
■ Or use your private images (creating a registry)
○ Provision
■ Alter configuration, install libraries, copy files from host
machine, etc
Docker
Dockerfile
12. FROM ubuntu:14.04
# install cowsay, and move the "default.cow" out, so we can overwrite it with "docker.cow"
RUN apt-get update && apt-get install -y cowsay --no-install-recommends
RUN rm -rf /var/lib/apt/lists/*
RUN mv /usr/share/cowsay/cows/default.cow /usr/share/cowsay/cows/orig-default.cow
# "cowsay" installs to /usr/games
ENV PATH $PATH:/usr/games
COPY docker.cow /usr/share/cowsay/cows/
RUN ln -sv /usr/share/cowsay/cows/docker.cow /usr/share/cowsay/cows/default.cow
CMD ["cowsay"]
Docker
Dockerfile example (docker/whalesay:latest)
13. ● Build your own image
○ And use it as base for new recipes
● Create network
○ And connect containers
● Mount local directory in docker’s filesystem
○ -v localDir:/tmp/localDir
● Share hardware (display, usb, etc) between host and docker
Docker
Docker features
14. ● Docker compose
○ Orchestrate several containers
○ Complex recipes to launch complete environments
■ Ex. Wordpress, Ruby on Rails
● and other new tools
● ...up to docker swarm or kubernetes
Docker
Managing several containers
15. ● From Vagrant to Docker
○ First use with new projects
● Actual use
○ Development (14 “fat” containers)
○ Staging
● Production?
○ Not yet. But using same provisioning recipes.
Docker
How we use docker at ulabox