Slide 1

Slide 1 text

Docker for Development Pedro Gil @pgcandeias Container Docks, 2/12 © 2012 Louis Vest - https://flic.kr/p/bSrWHc

Slide 2

Slide 2 text

About me • Mostly into dynamic languages (php/js/python) • Head of Platform Engineering at HelloFresh • Migrating monoliths into microservices • Taking care of the services and tools used by our developers

Slide 3

Slide 3 text

What’s Docker? “Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.” https://www.docker.com/what-docker

Slide 4

Slide 4 text

Containers • Similar to virtual machines • Don’t need a whole OS per container • Much smaller than VMs https://www.docker.com/what-docker

Slide 5

Slide 5 text

VM vs container architecture https://www.docker.com/what-docker

Slide 6

Slide 6 text

Container benefits • Consume very little memory and disk • We can run lots and lots of them in a laptop • Spin up in under a second • Disposable Container © 2013 www.GlynLowe.com - https://flic.kr/p/hD7Jqz

Slide 7

Slide 7 text

So basically… We can run very complex distributed systems with dozens of hosts We can closely simulate production topology In our laptops! © 2015 Dirk Dallas - https://flic.kr/p/qZbDqf

Slide 8

Slide 8 text

What’s Docker? Docker is witchcraft. La Bruja del Mar © 2012 Sergio Otero - https://flic.kr/p/eFAV7T

Slide 9

Slide 9 text

That’s nice, kid but what’s in it for me? © Lucasfilm Ltd - http://www.starwars.com/databank/han-solo

Slide 10

Slide 10 text

First, a little perspective Let’s take a look at where we came from

Slide 11

Slide 11 text

In the olden days… • We worked on bare metal • Language interpreters, databases and web servers all installed in our machines • Working with multiple versions of the same thing (language, database, etc) sucked • Environment management solutions emerged • Many differences between development and production. Ibiza Medieval 2011 © 2011 Juan Pacheco Tirado - https://flic.kr/p/9Fnrnp

Slide 12

Slide 12 text

Enter Vagrant • Easy virtualization • Same environment in development and production • Different VMs for different projects, each with its own dependency versions • Easy to share https://commons.wikimedia.org/wiki/File:Vagrant.png

Slide 13

Slide 13 text

Vagrant issues • Still a lot of overhead • No easy way to accurately represent large, diverse topologies • Untenable for large, distributed applications https://www.docker.com/what-docker

Slide 14

Slide 14 text

Container benefits • Consume very little memory and disk • We can run lots and lots of them in a laptop • Spin up in under a second • Disposable https://www.docker.com/what-docker

Slide 15

Slide 15 text

Docker architecture

Slide 16

Slide 16 text

Docker requires Linux Other OSes, such as OS X or Windows, require using some sort of linux based virtual machine for Docker Engine to run. Docker machine (previously boot2docker) is basically just a linux VM with docker engine inside.

Slide 17

Slide 17 text

Use docker machine. Problem? • Broken filesystem sync • Live code editing doesn’t work • No big deal for compiled languages, but it sucks for php, JS, python, etc • Accessing each app on a different port also sucks • So yes, Sherlock, problem. http://www.independent.co.uk/

Slide 18

Slide 18 text

Vagrant to the rescue • Proper NFS shares allow code changes to propagate to containers • Multiple network interfaces allow multiple apps to run on port 80 (for example) • Really nice customisation all around • Still easy to share https://commons.wikimedia.org/wiki/File:Vagrant.png

Slide 19

Slide 19 text

docker compose creating a nice application cluster with your code and all ancillary services like databases

Slide 20

Slide 20 text

docker run vs docker exec

Slide 21

Slide 21 text

docker run -ti ubuntu bin/bash • Pulls the ubuntu image from a registry • Creates a new container • Allocates a filesystem and mounts a read-write layer • Allocates a network / bridge interface • Sets up an IP address • Executes a process that you specify (hello) • Captures and provides application output • Stops the container as soon as the command is done

Slide 22

Slide 22 text

docker exec -ti ubuntu_1 bin/bash • Executes a comand in an already running container • In this case, executing bash means you get a shell • This is how you can see logs for an application server, for instance • Any changes made during this session persist in the running instance

Slide 23

Slide 23 text

In summary • Docker allows developing on a topology that resembles production much more closely than bare metal or VMs • Doesn’t run on OS X but we can fix that using a vagrant box with docker-engine installed • docker-compose lets us define complex clusters easily for development • Containers are cheap. Kill them, restart them, change their versions easily.

Slide 24

Slide 24 text

Thank you! Pedro Gil @pgcandeias [email protected] github.com/pgscandeias Container Docks, 2/12 © 2012 Louis Vest - https://flic.kr/p/bSrWHc