Docker and its Ecosystem

33f4da946e4712d9aac7ea915fdc71e4?s=47 Julien Vey
October 31, 2014

Docker and its Ecosystem

33f4da946e4712d9aac7ea915fdc71e4?s=128

Julien Vey

October 31, 2014
Tweet

Transcript

  1. Docker AND ITS ECOSYSTEM

  2. Julien Vey Numergy @julienvey Pierre Padrixe Numergy @undefd About us…

  3. The reason behind Docker

  4. « Works on my machine » We all said it

    once
  5. The Matrix from hell My Machine Your Machine QA Staging

    Prod Web App ? ? ? ? ? Back Office ? ? ? ? ? Queue ? ? ? ? ? Workers ? ? ? ? ? DB ? ? ? ? ?
  6. The Analogy ? ? ? ? ? ? ? ?

    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  7. The shipping container

  8. Why it works for Industry

  9. Standard size everything can be built to manipulate containers Focus

    on real work Shipping companies only care about shipping container
  10. The Analogy

  11. The Matrix from hell My Machine Your Machine QA Staging

    Prod Web App Back Office Queue Workers DB
  12. Containers Virtual Machines vs

  13. Bare Metal OS Hypervisor OS Guest Application VM OS Guest

    Application VM Bare Metal OS D o c k e r Application Container Application Container
  14. Why Containers ?

  15. Lightweight Fast Spawn Performance Isolated

  16. Docker Internals

  17. Linux Kernel Layer FS (DeviceMapper, AUFS) CGROUPS Namespaces Container Technology

    (LXC, LibContainer…) Docker
  18. CGroups Control resource allocations (CPU, Memory, Disk, I/O) Namespaces Restrict

    your view of the system (Mounts, PID…)
  19. Docker Toolbox

  20. Docker Engine runs containers CLI + Docker Daemon

  21. $ docker run ubuntu echo Hello Hello Docker Engine Run

    a container
  22. $ docker run -d nginx 61af09d5d50b Docker Engine Run a

    container in « detach » mode
  23. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS

    61af09d5d50b nginx:latest "nginx -g 'daemon of 12 hours ago Up 4 seconds 443/tcp, 80/tcp Docker Engine List running containers
  24. Docker Hub Cloud Service Share containers Automatic build of images

  25. Docker Images

  26. Images represents the state of a container

  27. Create Images from a container $ docker commit 61af09d5d50b 10b9b93d189b

  28. Create Images from a Dockerfile $ docker build -t myimage

    .
  29. FROM ubuntu:14.04 RUN apt-get update RUN apt-get install -y mongodb-org

    VOLUME ["/data/db"] WORKDIR /data EXPOSE 27017 EXPOSE 28017 ENTRYPOINT ["mongod"]
  30. Distribute Images on Docker Hub $ docker push myuser/myimage $

    docker pull myuser/myimage
  31. Docker Networking

  32. Docker creates containers in its Own internal network with their

    Own IP address
  33. Host eth0 192.168.0.12 docker0 172.17.42.1

  34. Container A Host eth0 172.17.42.2 eth0 192.168.0.12 docker0 172.17.42.1

  35. Container A Host eth0 172.17.42.2 eth0 192.168.0.12 docker0 172.17.42.1 eth0

    172.17.42.3 Container B
  36. What happens When…

  37. Container A Host eth0 172.17.42.2 eth0 192.168.0.12 docker0 172.17.42.1 eth0

    172.17.42.3 $ ping 172.17.42.3 Container B
  38. Container A Host eth0 172.17.42.2 eth0 192.168.0.12 docker0 172.17.42.1 eth0

    172.17.42.3 $ ping 172.17.42.3 Container B
  39. Container A Host eth0 172.17.42.2 eth0 192.168.0.12 docker0 172.17.42.1 eth0

    172.17.42.3 $ ping google.fr Container B
  40. Container A Host eth0 172.17.42.2 eth0 192.168.0.12 docker0 172.17.42.1 eth0

    172.17.42.3 $ ping 172.17.42.2 X Container B
  41. Port Mapping Bind a port on the host with a

    port on the container $ docker run -d -p 80:8080 webapp
  42. Container A Host eth0 172.17.42.2 eth0 192.168.0.12 docker0 172.17.42.1 eth0

    172.17.42.3 $ docker run -d -p 80:8080 A $ telnet 192.168.0.12 80 :8080 :80 Container B
  43. Docker Links Bind containers together

  44. Disclaimer: Only works on the same host

  45. Links Bind containers together $ sudo docker run -d --name

    dbcont dbimage $ sudo docker run -d -P --name web \ --link dbcont:db webapp
  46. Links What it does - Injects Environment variables $ sudo

    docker run -d -P --name web \ --link dbcont:db webapp env DB_NAME=/web/db DB_PORT=tcp://172.17.0.5:5432 DB_PORT_5432_TCP=tcp://172.17.0.5:5432 DB_PORT_5432_TCP_PROTO=tcp DB_PORT_5432_TCP_PORT=5432 DB_PORT_5432_TCP_ADDR=172.17.0.5
  47. Links What it does - Updates container /etc/hosts $ sudo

    docker run -P --name web \ --link dbcont:db webapp env root@aed84ee21bde:/opt/webapp# cat /etc/hosts 172.17.0.7 aed84ee21bde . . . 172.17.0.5 db
  48. Docker Volumes Manage data in containers

  49. Volumes Sharing volumes between the host and containers sudo docker

    run -d \ -v /src/webapp:/opt/webapp \ webapp
  50. Volumes Sharing volumes between containers $ sudo docker run -d

    \ -v /dbdata --name dbdata \ database $ sudo docker run -d \ --volumes-from dbdata database
  51. Docker Orchestration

  52. Using Docker containers on a Single machine is Simple

  53. Orchestrating Docker containers on Multiple nodes is Hard

  54. Config file based tools Fleet, Fig, Maestro, Ansible, Terraform… API

    based tools Mesos, Helios, Kubernetes… PaaS Solutions Flynn, Deis, OpenShift, CloudFoundry (Diego)… OpenStack Solum, nova-docker…
  55. Fleet systemd, etcd… [Unit] Description=My Apache Frontend After=docker.service Requires=docker.service [Service]

    TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker kill apache1 ExecStartPre=-/usr/bin/docker rm apache1 ExecStartPre=/usr/bin/docker pull coreos/apache ExecStart=/usr/bin/docker run -rm --name apache1 -p 80:80 coreos/apache /usr/sbin/apache2ctl ExecStop=/usr/bin/docker stop apache1 [X-Fleet] Conflicts=apache.*.service
  56. Fleet systemd, etcd, (works great with CoreOS) Start a fleet

    Unit $ fleetctl start myapp.service List all units $ fleetctl list-units UNIT MACHINE ACTIVE SUB myapp.service c9de9451.../10.10.1.3 active running apache.1.service 491586a6.../10.10.1.2 active running apache.2.service 148a18ff.../10.10.1.1 active running List "fleet enables" machines $ fleetctl list-machines MACHINE IP METADATA 148a18ff-6e95-4cd8-92da-c9de9bb90d5a 10.10.1.1 - 491586a6-508f-4583-a71d-bfc4d146e996 10.10.1.2 - c9de9451-6a6f-1d80-b7e6-46e996bfc4d1 10.10.1.3 -
  57. Apache Mesos Cluster Manager Orchestrate applications deployment on a Shared

    pool of resources
  58. Kubernetes Containers the Google way Originally designed for Google internal

    container cluster management API and CLI to orchestrate containers Use Providers for the underlying Infrastructure
  59. OpenStack Nova-Docker Hypervisor driver for OpenStack Nova Compute Launch Containers

    as VMs Store Images in Glance
  60. OpenStack Heat - the Orchestration Engine heat_template_version: 2013-05-23 description: A

    load-balancer server parameters: image: type: string key_name: type: string flavor: type: string resources: server: type: OS::Nova::Server properties: flavor: {get_param: flavor} image: {get_param: image} key_name: {get_param: key_name}
  61. OpenStack Heat - the Orchestration Engine heat_template_version: 2013-05-23 description: >

    Heat template to deploy Docker containers to an existing host resources: nginx-01: type: DockerInc::Docker::Container properties: image: nginx docker_endpoint: 'tcp://192.168.1.207:2345'
  62. OpenStack Solum, CI/CD for OpenStack describe development pipelines (dev ->

    stage…) run unit tests in containers create heat stacks for integration tests manage heat stacks for environments
  63. Docker Service Discovery

  64. Containers need to discover its peers

  65. Environment variables Inject environment variable at runtime $ docker run

    \ -e SQL_IP=192.168.1.21 \ -e SQL_PORT=3306 \ webapp
  66. bind-mount Inject configuration files at runtime $ docker run \

    -v /home/user/sql.conf:/sql.conf \ webapp
  67. DNS Add DNS records for each service

  68. Ambassador Pattern Delegate multi-host service discovery to an Ambassador

  69. Host DB DB Container Host Web Web Container ?

  70. Host DB DB Container Ambassador Host Web Web Container Ambassador

    docker link docker link
  71. Host DB DB Container Ambassador Host Web Web Container Ambassador

    docker link docker link
  72. Host DB DB Container Ambassador Host Web Web Container Ambassador

    docker link docker link ?
  73. Ambassador Pattern The solutions Grand Ambassador https://github.com/cpuguy83/docker-grand-ambassador Key-value Consul, etcd…

  74. Thank you! Questions ?