Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Meetup Docker 101

Meetup Docker 101

A gentle introduction to Docker

ubermuda

May 28, 2014
Tweet

More Decks by ubermuda

Other Decks in Technology

Transcript

  1. Who's talking? • Geoffrey Bachelet • Stage1.io : continuous staging

    • Gustave.io : interactive staging • Freelance Developer / Trainer @ubermuda
  2. Container Engine? Based on the Linux kernel's LXC instructions Processes

    and resources isolation "chroot" on steroids / super lightweight VMs
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. $  docker  ps   CONTAINER  ID    ...    PORTS

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

      923cb190dbc3    ...    0.0.0.0:49155-­‐>80/tcp   ! $  curl  http://localhost:49155   <html>   <head>   <title>Welcome  to  nginx!</title>   ...
  11. 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"]
  12. 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"]
  13. 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"]
  14. 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"]
  15. 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"]
  16. 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"]
  17. 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"]
  18. 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"]
  19. 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"]
  20. • 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
  21. Docker CLI • run  [-­‐d] : execute a container •

    attach : attach stdout • ps : list running containers • images : list existing images • rm  /  rmi : delete containers / images
  22. Volumes Like NFS for docker (except it works) Store data

    in data containers Easily backup data containers
  23. Docker Remote API Rest(-ish) HTTP API for Docker ! Third

    party client libraries: dockerode, Docker-php, etc