2. Virtualisation as you may know it
• Type 1 Hypervisor: VMWare ESXi, Xen Project
• Native / Full Virtualisation / Baremetal Hypervisor
• Make it possible to run many instances of an operating system or indeed different operating systems in parallel on a single machine
• Type 2 Hypervisor: VirtualBox, QEmu, Parallels
• Needs an underlaying operating system to run, then also allows for running different operating systems in parallel.
• HVM (Hardware Virtual Machine) and
• HVM Pros:
• Simulates a complete hardware environment.
• Guest server executes in complete isolation.
• Each guest server can run on its own OS -- can run Linux and Windows.
• More stability.
• HVM Cons:
• Slower overall server performance because of the hardware overhead.
• PV (Paravirtual Machine)
• PV Pros:
• Lower virtualization overhead.
• Stability and performance is close to the real servers and hardware virtualization.
• PV Cons:
• Supports only Linux.
• Poor portability and compatibility.
• More difficult to implement.
• OS options can not be changed during the installation.
• Can not compile and install a custom kernel.
• Both the host and guest kernel must be patched.
Source: https://support.cloud.engineyard.com/hc/en-us/articles/205407968-HVM-vs-PV
4. Container vs. Virtualisation
• Containers
• Operating-system-level virtualization
• is a server virtualization method where the kernel of an operating system allows for multiple isolated user space
instances, instead of just one
• Other names: Virtualization Engines (VE), Virtual Private Servers (VPS), Jails (on BSD)
• Can be seen as an advanced implementation of the standard chroot mechanism
• Chroot is an operation that changes the apparent root directory for the current running process and their children. A program that is run in such a modified
environment cannot access files and commands outside that environmental directory tree. This modified environment is called a chroot jail.
• Containers can be called “VM’s without the hypervisor”
• Containers virtualize (Linux) Operating Systems!
• Containers virtualize Applications (running on the according virtualized Operating Systems)!
8. Why Docker?
• Open Source!
• -> Low(er) total cost of ownership!
• Lightweight, Stable, proven
• Google, Amazon, Ebay, Rackspace, just to name a few, are using it productively
• Deployable / Build once, run anywhere / Configure once, run anything
• Huge eco system of tools around it
• Improves Development Agility
• Testing, Deployment...
10. Live Example
• WE NEED A NEW DEV SETUP!
FAST!
• We need a web server!
• We need a database and a management UI!
• Also we need data!
• Quick!
11. Live Example
• Web server: Apache!
•
Dynamic PL: PHP!
• Database: Ah, let’s take Mongo!
• Data? Yeah sure! Let’s put them
in a data container (best practice!)
12. Live Example
• DB Administration Tool?
• <google, google>
• Yeah let’s take MongoDB Express
13. Live Example
• Let’s see if DockerHub has
something appropriate…
• Apache & PHP: tutum/apache-php
• https://registry.hub.docker.com/u/tutum/apache-php/
• MongoDB: mongo
• https://registry.hub.docker.com/_/mongo/
• Data Container
• With rsync access, please
• Yeah: https://registry.hub.docker.com/u/nabeken/docker-volume-container-rsync/
• Ok, needed modifications:
https://registry.hub.docker.com/u/chimeradev/docker-webroot-volume-rsync/
15. Container Workflows
• Create your own images
• → Dockerfile
• Manually or auto-generated
• Can’t handle variables unfortunately
• Use images created by other users
• → DockerHub
Source: https://support.cloud.engineyard.com/hc/en-us/articles/205407968-HVM-vs-PV
FROM ubuntu:14.04
MAINTAINER Andreas Katzig <akatzig@chimera-entertainment.de>
ENV HOME /opt/mongooseim
ENV MONGOOSEIM_VERSION 1.5
ENV DEBIAN_FRONTEND noninteractive
# add packages
RUN apt-get install wget -y
RUN wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
RUN dpkg -i erlang-solutions_1.0_all.deb
RUN wget http://packages.erlang-solutions.com/debian/erlang_solutions.asc
RUN apt-key add erlang_solutions.asc
RUN apt-get -q update
RUN apt-get install mongooseim -y
ADD templates/ /templates/
EXPOSE 80 5222 5280 5269
# Make shell scripts executable
RUN chmod 755 /templates/*.sh
CMD cd /usr/lib/mongooseim/etc/ && /templates/setup_configs.sh && /templates/start_mongooseim.sh
Dockerfile
16. Live Example
• Now get these images down and those containers running!
• The order of starting containers is important!
• 1.)
docker run -d --name webadmin-data -p 10873:873 -e ALLOW='62.245.239.122/32' -e OWNER='www-data'
-e GROUP='www-data' chimeradev/docker-webroot-volume-rsync
• 2.)
docker run -d --name webadmin-mongodb -p 27017:27017 --volumes-from webadmin-data mongo
--smallfiles
• 3.)
docker run -d --name mongo-express -p 8081:8081 --link nex-webadmin-mongodb:mongo
knickers/mongo-express
• 4.)
docker run -d --name webadmin --volumes-from webadmin-data --link webadmin-mongodb:mongo -p 81:80
asteris/apache-php-mongo