Docker 101

& how to run multiple Drupal environments with ease

Saul Willers @ PlexityNet

The problem: Matrix from hell

Drupal 6
(PHP <= 5.3)
? ? ? ? ? ?
Drupal 7
(5.3 >= PHP <= 5.4)
? ? ? ? ? ?
Drupal 8
(PHP >= 5.4)
? ? ? ? ? ?
DB (MariaDB / MySQL / MongoDB) ? ? ? ? ? ?
Apache Solr
(Solr 3 / 4)
? ? ? ? ? ?
My laptop Your laptop QA Staging Prod on VM Prod on bare metal

Another matrix from hell

Solution: The intermodal shipping container

(This is a somewhat overused analogy in Docker, but with good reason)

Solved!

Solutions to the deployment problem:

the Linux container

Linux containers (LXC)

  • In the kernel since Jan 2008
  • Units of software delivery
  • Run everywhere (regardless of kernel version or host distro)
  • Run anything (if it can run on a Linux kernel it can run)
  • Google's been using containers for years (everything at Google runs in containers, they start over 2 billion of them every week)

Containers vs VMs

Containerisation is the new virtualisation

It's chroot on steroids

  • container = isolated process(es)
  • Own process space
  • Own network interface
  • Can run stuff as root

Compute efficiency: almost no overhead

  • Processes are isolated, but run straight on the host
  • CPU performance = native performance
  • Memory performance = a few % shaved off for (optional) accounting
  • Network performance = small overhead (can be reduced to zero)

Docker

Open Source engine to commoditise LXC

(i.e. make containers ridiculously easy to use)

Why are Docker containers lightweight?

Docker basics

  • Image
  • Registry
  • Container

Building Docker images with a Dockerfile

FROM ubuntu
MAINTAINER Saul Willers 

RUN apt-get install -y apache2

EXPOSE 80

ENTRYPOINT ["/usr/sbin/apache2"]
CMD ["-D", "FOREGROUND"]

Building the image

$ sudo docker build -t="plexitynet/apache2" .

Running the container

$ sudo docker run -d -p 80 plexitynet/apache2

registry.hub.docker.com Shared repos

Demo time!

$ sudo docker ...

Docker is young, but it's future is bright

  • Little more than a year old
  • Popularity/growth has been exponential, right place right time
  • Makes managing complex apps a lot easier
  • Drupal testbot is moving to Docker drupal.org/project/drupalci_testbot

Resources

Questions?