Slide 1

Slide 1 text

Docker 101 Geoffrey Bachelet –@ubermuda

Slide 2

Slide 2 text

Who's talking? • Geoffrey Bachelet • Stage1.io : continuous staging • Gustave.io : interactive staging • Freelance Developer / Trainer @ubermuda

Slide 3

Slide 3 text

Container Engine? Based on the Linux kernel's LXC instructions Processes and resources isolation "chroot" on steroids / super lightweight VMs

Slide 4

Slide 4 text

Host OS Hypervisor Guest OS Guest OS Guest OS Guest OS App App App App Host OS Docker + LXC App App App App VMs vs Containers

Slide 5

Slide 5 text

VMs vs Containers LXC / Jails / Zones / etc Uses the host's kernel Boots in seconds 0 overhead (almost) Easy to pass around Hypervisor Boots a complete OS Boots in minutes Guest OS' overhead Several Go images

Slide 6

Slide 6 text

Image vs Container

Slide 7

Slide 7 text

credit: http:/ /docs.docker.io/en/latest/terms/image/ Image

Slide 8

Slide 8 text

Container credit: http:/ /docs.docker.io/en/latest/terms/image/

Slide 9

Slide 9 text

Create a container

Slide 10

Slide 10 text

$  docker  run  -­‐i  -­‐t  stackbrew/ubuntu  /bin/bash   ! root@21d86a0b8387:/#

Slide 11

Slide 11 text

Commit the container

Slide 12

Slide 12 text

root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $  docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  sflive/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY            TAG                  IMAGE  ID   sflive/nginx          latest            240198b750c3

Slide 13

Slide 13 text

root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $  docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  sflive/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY            TAG                  IMAGE  ID   sflive/nginx          latest            240198b750c3

Slide 14

Slide 14 text

root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $  docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  sflive/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY            TAG                  IMAGE  ID   sflive/nginx          latest            240198b750c3

Slide 15

Slide 15 text

root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $  docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  sflive/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY            TAG                  IMAGE  ID   sflive/nginx          latest            240198b750c3

Slide 16

Slide 16 text

Run the image

Slide 17

Slide 17 text

$  docker  run  -­‐p  80  sflive/nginx  nginx  -­‐g  'daemon  off;'

Slide 18

Slide 18 text

$  docker  run  -­‐p  80  sflive/nginx  nginx  -­‐g  'daemon  off;'

Slide 19

Slide 19 text

$  docker  run  -­‐p  80  sflive/nginx  nginx  -­‐g  'daemon  off;'

Slide 20

Slide 20 text

$  docker  run  -­‐p  80  sflive/nginx  nginx  -­‐g  'daemon  off;'

Slide 21

Slide 21 text

$  docker  run  -­‐p  80  sflive/nginx  nginx  -­‐g  'daemon  off;'

Slide 22

Slide 22 text

$  docker  run  -­‐p  80  sflive/nginx  nginx  -­‐g  'daemon  off;'

Slide 23

Slide 23 text

$  docker  ps   CONTAINER  ID    ...    PORTS   923cb190dbc3    ...    0.0.0.0:49155-­‐>80/tcp   ! $  curl  http://localhost:49155       Welcome  to  nginx!   ...

Slide 24

Slide 24 text

$  docker  ps   CONTAINER  ID    ...    PORTS   923cb190dbc3    ...    0.0.0.0:49155-­‐>80/tcp   ! $  curl  http://localhost:49155       Welcome  to  nginx!   ...

Slide 25

Slide 25 text

Dockerfile

Slide 26

Slide 26 text

credit: http:/ /docs.docker.io/en/latest/terms/image/

Slide 27

Slide 27 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 28

Slide 28 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 29

Slide 29 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 30

Slide 30 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 31

Slide 31 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 32

Slide 32 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 33

Slide 33 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 34

Slide 34 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 35

Slide 35 text

FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install  -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]

Slide 36

Slide 36 text

Features

Slide 37

Slide 37 text

• Docker CLI • run -d, attach, wait, ps, images, rm, rmi, etc • Networking • Ambassador, advanced routing, etc • Volumes • Data containers, bindmounting, etc • Docker Index • thousands of ready-made images • Docker Registry • private Docker Index • Remote API • dockerode, Docker-PHP, etc

Slide 38

Slide 38 text

Docker CLI • run  [-­‐d] : execute a container • attach : attach stdout • ps : list running containers • images : list existing images • rm  /  rmi : delete containers / images

Slide 39

Slide 39 text

Networking Link containers together Easy service discovery Ambassador pattern (service portability)

Slide 40

Slide 40 text

Volumes Like NFS for docker (except it works) Store data in data containers Easily backup data containers

Slide 41

Slide 41 text

Docker Index + Registry Thousands of ready-made images Private registry

Slide 42

Slide 42 text

Docker Remote API Rest(-ish) HTTP API for Docker ! Third party client libraries: dockerode, Docker-php, etc

Slide 43

Slide 43 text

Orchestration

Slide 44

Slide 44 text

Host OS THE INTERNET container nginx mysql php5-fpm

Slide 45

Slide 45 text

Host OS THE INTERNET nginx mysql php5-fpm /var/www /var/lib/mysql

Slide 46

Slide 46 text

Not built-in Lots of third-party tools ! maestro-ng, Fig, Gaudi, etc.

Slide 47

Slide 47 text

Pets vs Cattle

Slide 48

Slide 48 text

Use cases

Slide 49

Slide 49 text

Dev. environments Continuous integration Continuous deployment 0 downtime deployment Private PaaS

Slide 50

Slide 50 text

Thanks! https://speackerdeck.com/ubermuda/meetup-docker-101 Geoffrey Bachelet – @ubermuda