6. Docker vs VM
Guest OS
Hardware
Host OS
Hypervisor (Type2)
Guest OS Guest OS
Libs Libs Libs
App A App A’ App B
Hardware
Host OS
Libs Libs Libs
App A App A’ App B
Container
VM
Docker Engine
7. Components and Tools
Docker Engine: Creates and runs Docker containers
Docker Registry: Open source Docker image distribution
Docker Compose: Define multi-container applications
Docker Machine: Automated Docker provisioning
Docker Swarm: Host clustering and container scheduling
9. Typical Workflow
$ docker run -i -t ubuntu /bin/bash
Pulls the “ubuntu” image
Creates a new container
Allocates a filesystem and mounts a read-write layer
Allocates a network / bridge interface
Sets up an IP address
11. Union File System
Add Emacs
Kernel
All layers except the topmost are readonly
Add Apache
(writable)
(1)
(2)
(3)
(4)
Image
Container
Layers
12. Data volumes
Independent of the container’s lifecycle
Can be shared and reused among containers
Changes to a data volume are made directly
Data volumes persist even if the container is deleted
13. Basic Networking
Network port mapping
$ docker run -d -p 80:5000 my/webapp python app.py
The linking system
$ docker run -d -P --name web --link db:db
my/webapp python app.py
14. FROM ubuntu
MAINTAINER Kimbro Staken
RUN apt-get install -y software-properties-common python
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs
RUN mkdir /var/www
ADD app.js /var/www/app.js
CMD ["/usr/bin/node", "/var/www/app.js"]
Dockerfile1
15. # A basic apache server. To use either add or bind mount content under /var/www
FROM ubuntu:12.04
MAINTAINER Kimbro Staken version: 0.1
RUN apt-get update && apt-get install -y apache2 && apt-get clean && rm -rf /var/lib/apt/lists/*
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
Dockerfile2
16. Docker-Compose
Start, stop and rebuild services
View the status of running services
Stream the log output of running services
Run a one-off command on a service
18. Docker-Machine
I want to run Docker on Mac or Windows
Provisions a local virtual machine with Docker Engine
Gives the ability to connect to it and execute commands
I want to provision Docker hosts on remote systems