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

Docker and its Ecosystem

Julien Vey
October 31, 2014

Docker and its Ecosystem

Julien Vey

October 31, 2014
Tweet

More Decks by Julien Vey

Other Decks in Programming

Transcript

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

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

    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  3. Standard size everything can be built to manipulate containers Focus

    on real work Shipping companies only care about shipping container
  4. The Matrix from hell My Machine Your Machine QA Staging

    Prod Web App Back Office Queue Workers DB
  5. 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
  6. $ 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
  7. 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"]
  8. Port Mapping Bind a port on the host with a

    port on the container $ docker run -d -p 80:8080 webapp
  9. 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
  10. Links Bind containers together $ sudo docker run -d --name

    dbcont dbimage $ sudo docker run -d -P --name web \ --link dbcont:db webapp
  11. 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
  12. 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
  13. Volumes Sharing volumes between the host and containers sudo docker

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

    \ -v /dbdata --name dbdata \ database $ sudo docker run -d \ --volumes-from dbdata database
  15. 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…
  16. 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
  17. 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 -
  18. 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
  19. 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}
  20. 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'
  21. 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
  22. Environment variables Inject environment variable at runtime $ docker run

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

    -v /home/user/sql.conf:/sql.conf \ webapp