$30 off During Our Annual Pro Sale. View Details »

Docker from basics to orchestration (PHPConfBr2015)

Docker from basics to orchestration (PHPConfBr2015)

Talk given at PHP conference Brasil 2015 about Docker

Wellington F. Silva

December 03, 2015
Tweet

More Decks by Wellington F. Silva

Other Decks in Technology

Transcript

  1. Docker
    From basics to orchestration

    View Slide

  2. Credits
    Special thanks to all the people who made and released
    these awesome resources for free:
    ◎ Presentation template by SlidesCarnival
    ◎ Photographs by Unsplash & Death to the Stock Photo
    (license)
    ◎ Dark wood background by The pattern library

    View Slide

  3. About Me

    View Slide

  4. Overview

    View Slide

  5. Overview
    ◎ Environment Issues
    ◎ Virtualization
    ◎ LXC
    ◎ Docker
    ○ features
    ○ demo
    ◎ Machine
    ◎ Orchestration
    ○ tools
    ○ demo
    ◎ Swarm
    ○ demo
    ◎ Q&A

    View Slide

  6. Environment Issues

    View Slide

  7. Environment Issues
    ◎ substr vs mb_substr functions

    View Slide

  8. Environment Issues
    ◎ substr vs mb_substr functions
    ◎ short open tags: =

    View Slide

  9. Environment Issues
    ◎ substr vs mb_substr functions
    ◎ short open tags: =
    ◎ syntax changes between versions: array(); e [];

    View Slide

  10. Environment Issues
    ◎ substr vs mb_substr functions
    ◎ short open tags: =
    ◎ syntax changes between versions: array(); e [];
    ◎ extensions that we forget to install in
    production: php-memcached, redis, amqp,
    etc.

    View Slide

  11. Environment Issues
    ◎ substr vs mb_substr functions
    ◎ short open tags: =
    ◎ syntax changes between versions: array(); e [];
    ◎ extensions that we forget to install in
    production: php-memcached, redis, amqp,
    etc.
    ◎ different upload file settings in different
    servers

    View Slide

  12. View Slide

  13. View Slide

  14. Virtualization

    View Slide

  15. ◎ 1960 - inspired by cpu time sharing
    Virtualization - History

    View Slide

  16. ◎ 1960 - inspired by cpu time sharing
    ◎ IBM 370 - First instructions to support
    software virtualization, CP/CMS allow running
    more than one instance simultaneously
    Virtualization - History

    View Slide

  17. ◎ 1960 - inspired by cpu time sharing
    ◎ IBM 370 - First instructions to support
    software virtualization, CP/CMS allow running
    more than one instance simultaneously
    ◎ IBM z/VM - First success case, all hardware
    were virtualized
    Virtualization - History

    View Slide

  18. ◎ 1960 - inspired by cpu time sharing
    ◎ IBM 370 - First instructions to support
    software virtualization, CP/CMS allow running
    more than one instance simultaneously
    ◎ IBM z/VM - First success case, all hardware
    were virtualized
    ◎ until nineties only client/server applications
    Virtualization - History

    View Slide

  19. ◎ 1960 - inspired by cpu time sharing
    ◎ IBM 370 - First instructions to support
    software virtualization, CP/CMS allow running
    more than one instance simultaneously
    ◎ IBM z/VM - First success case, all hardware
    were virtualized
    ◎ until nineties only client/server applications
    ◎ 2000+ - CPUs with virtualization support,
    hypervisors: VMWare, Xen, KVM, VirtualBox,
    etc
    Virtualization - History

    View Slide

  20. Virtualization - Hypervisors

    View Slide

  21. Virtualization - Stack

    View Slide

  22. ◎ Standard
    environment
    Virtualization - Pros & Cons

    View Slide

  23. ◎ Standard
    environment
    ◎ Improve resources
    utilization
    Virtualization - Pros & Cons

    View Slide

  24. ◎ Standard
    environment
    ◎ Improve resources
    utilization
    ◎ Easy data recovery
    Virtualization - Pros & Cons

    View Slide

  25. ◎ Standard
    environment
    ◎ Improve resources
    utilization
    ◎ Easy data recovery
    ◎ If host fails all VMs
    crashes together
    Virtualization - Pros & Cons

    View Slide

  26. ◎ Standard
    environment
    ◎ Improve resources
    utilization
    ◎ Easy data recovery
    Virtualization - Pros & Cons
    ◎ If host fails all VMs
    crashes together
    ◎ Troubleshooting
    more difficult

    View Slide

  27. ◎ Standard
    environment
    ◎ Improve resources
    utilization
    ◎ Easy data recovery
    Virtualization - Pros & Cons
    ◎ If host fails all VMs
    crashes together
    ◎ Troubleshooting
    more difficult
    ◎ Increase overhead

    View Slide

  28. LXC - Linux Containers

    View Slide

  29. LXC - Linux Containers
    ◎ Exists since Jul/2008 - Kernel 2.6.26+

    View Slide

  30. LXC - Linux Containers
    ◎ Exists since Jul/2008 - Kernel 2.6.26+
    ◎ Process isolation

    View Slide

  31. LXC - Linux Containers
    ◎ Exists since Jul/2008 - Kernel 2.6.26+
    ◎ Process isolation
    ◎ Network isolation

    View Slide

  32. LXC - Linux Containers
    ◎ Exists since Jul/2008 - Kernel 2.6.26+
    ◎ Process isolation
    ◎ Network isolation
    ◎ Memory limitation

    View Slide

  33. LXC - Linux Containers
    ◎ Exists since Jul/2008 - Kernel 2.6.26+
    ◎ Process isolation
    ◎ Network isolation
    ◎ Memory limitation
    ◎ File system isolation

    View Slide

  34. LXC - Pros & Cons
    ◎ Good resources
    isolation

    View Slide

  35. LXC - Pros & Cons
    ◎ Good resources
    isolation
    ◎ Run as a process, a
    single PID is created

    View Slide

  36. LXC - Pros & Cons
    ◎ Good resources
    isolation
    ◎ Run as a process, a
    single PID is created
    ◎ Reuse host
    resources (libs,
    kernel)

    View Slide

  37. LXC - Pros & Cons
    ◎ Good resources
    isolation
    ◎ Run as a process, a
    single PID is created
    ◎ Reuse host
    resources (libs,
    kernel)
    ◎ Starts much more
    faster than VMs

    View Slide

  38. LXC - Pros & Cons
    ◎ Volume share are
    difficult to do
    ◎ Good resources
    isolation
    ◎ Run as a process, a
    single PID is created
    ◎ Reuse host
    resources (libs,
    kernel)
    ◎ Starts much more
    faster than VMs

    View Slide

  39. LXC - Pros & Cons
    ◎ Volume share are
    difficult to do
    ◎ Architecture failure
    may lead to chroot
    attack
    ◎ Good resources
    isolation
    ◎ Run as a process, a
    single PID is created
    ◎ Reuse host
    resources (libs,
    kernel)
    ◎ Starts much more
    faster than VMs

    View Slide

  40. LXC - Pros & Cons
    ◎ Volume share are
    difficult to do
    ◎ Architecture failure
    may lead to chroot
    attack
    ◎ IO overhead
    ◎ Good resources
    isolation
    ◎ Run as a process, a
    single PID is created
    ◎ Reuse host
    resources (libs,
    kernel)
    ◎ Starts much more
    faster than VMs

    View Slide

  41. LXC - Pros & Cons
    ◎ Volume share are
    difficult to do
    ◎ Architecture failure
    may lead to chroot
    attack
    ◎ IO overhead
    ◎ Run on Linux hosts
    only
    ◎ Good resources
    isolation
    ◎ Run as a process, a
    single PID is created
    ◎ Reuse host
    resources (libs,
    kernel)
    ◎ Starts much more
    faster than VMs

    View Slide

  42. DOCKER

    View Slide

  43. Docker

    View Slide

  44. Docker
    Doki =>

    View Slide

  45. View Slide

  46. View Slide

  47. View Slide

  48. ◎ Portable
    Docker - Features

    View Slide

  49. ◎ Portable
    ◎ Versionable
    Docker - Features

    View Slide

  50. ◎ Portable
    ◎ Versionable
    ◎ Reusable
    Docker - Features

    View Slide

  51. ◎ Portable
    ◎ Versionable
    ◎ Reusable
    ◎ Copy-on-write
    Docker - Features

    View Slide

  52. ◎ Portable
    ◎ Versionable
    ◎ Reusable
    ◎ Copy-on-write
    ◎ Logging
    Docker - Features

    View Slide

  53. ◎ Portable
    ◎ Versionable
    ◎ Reusable
    ◎ Copy-on-write
    ◎ Logging
    ◎ Image change management
    Docker - Features

    View Slide

  54. ◎ Portable
    ◎ Versionable
    ◎ Reusable
    ◎ Copy-on-write
    ◎ Logging
    ◎ Image change management
    ◎ Automatic build
    Docker - Features

    View Slide

  55. ◎ Portable
    ◎ Versionable
    ◎ Reusable
    ◎ Copy-on-write
    ◎ Logging
    ◎ Image change management
    ◎ Automatic build
    ◎ Easy to share
    Docker - Features

    View Slide

  56. Docker - Features
    ◎ Private and public registry

    View Slide

  57. Docker - Features
    ◎ Private and public registry
    ◎ Server-client architecture

    View Slide

  58. Docker - Features
    ◎ Private and public registry
    ◎ Server-client architecture
    ◎ Client consume engine API

    View Slide

  59. Docker - Features
    ◎ Private and public registry
    ◎ Server-client architecture
    ◎ Client consume engine API
    ◎ Orchestration tools (compose, swarm,volume
    networks)

    View Slide

  60. Docker - Features
    ◎ Private and public registry
    ◎ Server-client architecture
    ◎ Client consume engine API
    ◎ Orchestration tools (compose, swarm,volume
    networks)
    ◎ Always innovating

    View Slide

  61. Docker - VM Comparison

    View Slide

  62. Docker - Quick Tips
    ◎ It is a container not a VM

    View Slide

  63. Docker - Quick Tips
    ◎ It is a container not a VM
    ◎ Container images are like VM boxes

    View Slide

  64. Docker - Quick Tips
    ◎ It is a container not a VM
    ◎ Container images are like VM boxes
    ◎ Images are state, container runs it

    View Slide

  65. Docker - Install
    ◎ Follow instructions for your OS in http://docs.
    docker.com/installation

    View Slide

  66. Docker - Install
    ◎ Follow instructions for your OS in http://docs.
    docker.com/installation
    ◎ Several distros supported

    View Slide

  67. Docker - Install
    ◎ Follow instructions for your OS in http://docs.
    docker.com/installation
    ◎ Several distros supported
    ◎ Mac OS X and Windows needs a VM to act
    like a Docker host - Boot2docker

    View Slide

  68. Docker - Install
    ◎ Follow instructions for your OS in http://docs.
    docker.com/installation
    ◎ Several distros supported
    ◎ Mac OS X and Windows needs a VM to act
    like a Docker host - Boot2docker
    ◎ There is roadmap to run Linux container on
    FreeBSD host

    View Slide

  69. Docker - Install
    ◎ Follow instructions for your OS in http://docs.
    docker.com/installation
    ◎ Several distros supported
    ◎ Mac OS X and Windows needs a VM to act
    like a Docker host - Boot2docker
    ◎ There is roadmap to run Linux container on
    FreeBSD host
    ◎ Windows containers running on Windows
    hosts will be available on Windows Server
    2016

    View Slide

  70. Docker - Beggining
    ◎ run
    ◎ pull
    ◎ commit
    ◎ push
    ◎ exec
    ◎ ps
    ◎ images
    ◎ inspect
    ◎ rm
    ◎ rmi

    View Slide


  71. Talk is cheap, show me the code.
    Linus Torvalds

    View Slide

  72. pull
    commit
    push
    Docker - Images
    Dockerfile

    View Slide

  73. Docker - Improving
    ◎ Volume
    ○ list, create, inspect
    ◎ Port expose and port mapping
    ◎ Links between containers
    ◎ Network
    ○ list, create,inspect, connect

    View Slide

  74. Second Demo

    View Slide

  75. Docker - Machine
    ◎ Creates virtual machines ready to run
    docker locally or on the cloud.
    ◎ drivers available:
    ○ Amazon Web Services, Microsoft Azure, Digital
    Ocean, Exoscale, Google Compute Engine,
    Microsoft Hyper-V, OpenStack, Rackspace, IBM
    Softlayer, Oracle VirtualBox, VMware vCloud Air,
    VMware Fusion, VMware vSphere and Generic

    View Slide

  76. Docker - Orchestration
    ◎ Docker Compose (Old FIG)

    View Slide

  77. Docker - Orchestration
    ◎ Docker Compose (Old FIG)

    View Slide

  78. Docker - Orchestration
    ◎ Docker Compose (Old FIG)

    View Slide

  79. Docker - Orchestration
    ◎ Docker Compose (Old FIG)
    ○ Config file: docker-compose.yml
    ○ Run: docker-compose up

    View Slide

  80. Docker - Orchestration
    ◎ Docker Compose (Old FIG)
    ○ Config file: docker-compose.yml
    ○ Run: docker-compose up
    ◎ Crane - http://getcrane.com
    ○ Config file: crane.json or crane.yaml
    ○ Run: crane lift

    View Slide

  81. Docker - Orchestration
    ◎ Docker Compose (Old FIG)
    ○ Config file: docker-compose.yml
    ○ Run: docker-compose up
    ◎ Crane - http://getcrane.com
    ○ Config file: crane.json or crane.yaml
    ○ Run: crane lift
    ◎ AZK - http://www.azk.io
    ○ Config file: Azkfile.js
    ○ Run: `azk agent start` and then `azk start`

    View Slide

  82. Third Demo

    View Slide

  83. Docker - Orchestration
    ◎ Docker Swarm
    ○ Orchestrate docker hosts
    ○ supports schedulers and node discovery services

    View Slide

  84. Last Demo

    View Slide

  85. Docker - Comming
    ◎ User namespaces
    ◎ Open Containers Initiative - by Linux Foundation:
    https://www.opencontainers.org/

    View Slide

  86. Voucher: php_conf2015
    Q&A
    Slides
    http://bit.ly/phpconfbr2015

    View Slide