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

Enfrentando o Docker em ambientes de desenvolvimento

Enfrentando o Docker em ambientes de desenvolvimento

Esta palestra descreve as semelhanças entre o esquema de virtualização comum e a virtualização com containers, introduz o Docker Engine e suas ferramentas como meio de agilizar e padronizar a configuração de ambientes de desenvolvimento.

Sérgio Vilar

March 16, 2016
Tweet

More Decks by Sérgio Vilar

Other Decks in Programming

Transcript

  1. FNBNCJFOUFTEFEFTFOWPMWJNFOUP
    &OGSFOUBOEPP%PDLFS

    View full-size slide

  2. 4ʡSHJP7JMBS
    4PGUXBSF&OHJOFFS

    View full-size slide

  3. 1BESPOJ[BÇÄPEPBNCJFOUFEF
    EFTFOWPMWJNFOUP

    View full-size slide

  4. 7JSUVBMJ[BÇÄP

    View full-size slide

  5. 7JSUVBMJ[BÇÄP
    Host OS (Windows, Linux, OSX)
    VM A (Guest OS) VM B (Guest OS)
    Virtualization provider (VMWare, Virtualbox)
    Dependencies (SO, bins) Dependencies (SO, bins)
    App A App B
    "NCJFOUF

    QBESPOJ[BEP

    View full-size slide

  6. &OHJOFRVFGBDJMJUBP
    EFTFOWPMWJNFOUPF
    EJTUSJCVJÇÄPEFXFCBQQT
    VTBOEPDPOUBJOFSTMJOVY

    View full-size slide

  7. Containers Linux
    w 7JSUVBMJ[BÇÄPBOÍWFMEF40RVFQFSNJUFSPEBSNÙMUJQMPTTJTUFNBT
    MJOVYJTPMBEPT
    w 1FSNJUFSPEBSVNNJOJ-JOVYEFOUSPEFVN-JOVYKÂFYJTUFOUF

    View full-size slide

  8. 7. %PDLFS$POUBJOFST
    $POUBJOFSTTÄPJTPMBEPT

    NBTDPNQBSUJMIBNP40F

    CJOTMJCTRVBOEPDPOWFOJFOUF

    View full-size slide

  9. 7JSUVBMJ[BÇÄPFN$POUBJOFST
    Host OS (Windows, OSX)
    VM (Guest OS + Docker Engine)
    Virtualization provider (VMWare, Virtualbox)
    MySQL 

    (LXC Container)
    App
    "NCJFOUF

    QBESPOJ[BEP
    Nginx

    (LXC Container)
    PHP-FPM

    (LXC Container)
    Link

    View full-size slide

  10. 7JSUVBMJ[BÇÄPFN$POUBJOFST
    Host OS (Linux)
    Docker Engine
    MySQL 

    (LXC Container)
    App
    Nginx

    (LXC Container)
    PHP-FPM

    (LXC Container)
    "NCJFOUF

    QBESPOJ[BEP

    View full-size slide

  11. 0RVFTÄP
    %PDLFS$POUBJOFST

    View full-size slide

  12. 4ÄPDPOUBJOFSTMJOVY
    JTPMBEPTDSJBEPTBQBSUJS
    EFVNBJNBHFN

    View full-size slide

  13. 6NBJNBHFNÉDSJBEBB
    QBSUJSEFJOTUSVÇÕFTRVF
    JOTUBMBNFDPOpHVSBN
    EFQFOEÊODJBTOFDFTTÂSJBT
    QSPWJTJPOBNFOUP

    View full-size slide

  14. %PDLFS)VC

    IVCEPDLFSDPN

    View full-size slide

  15. docker pull phpunit/phpunit

    View full-size slide

  16. $POTUSVJOEP
    TVBTQSÓQSJBT
    JNBHFOT

    View full-size slide

  17. 1 FROM ubuntu:14.04
    2
    3 # Install Python.
    4 RUN apt-get update
    5 RUN apt-get install -y python python-dev python-pip python-virtualenv
    6 RUN rm -rf /var/lib/apt/lists/*
    7
    8 # Define working directory.
    9 WORKDIR /data
    10
    11 # Define default command.
    12 CMD ["bash"]
    Dockerfile

    View full-size slide

  18. $BEBJOTUSVÇÄP36/
    BEJDJPOBVNBOPWB
    DBNBEBÁJNBHFN

    View full-size slide

  19. 2VBOUPNBJTDBNBEBT
    NBJTFTQBÇPBJNBHFN
    PDVQBSÂ

    View full-size slide

  20. 1 FROM ubuntu:14.04
    2
    3 # Install Python.
    4 RUN \
    5 apt-get update && \
    6 apt-get install -y python python-dev python-pip python-virtualenv && \
    7 rm -rf /var/lib/apt/lists/*
    8
    9 # Define working directory.
    10 WORKDIR /data
    11
    12 # Define default command.
    13 CMD ["bash"]
    Dockerfile
    Boa Prática

    View full-size slide

  21. $BNBEBTFNDPNVNTÄP
    DPNQBSUJMIBEBTFOUSF
    DPOUBJOFST

    View full-size slide

  22. 3PEBOEP

    $POUBJOFST

    View full-size slide

  23. docker run --name meubanco mariadb

    View full-size slide

  24. %PDLFS

    .BDIJOF

    GPSNFSCPPUEPDLFS

    View full-size slide

  25. 'FSSBNFOUBRVFQFSNJUF
    DSJBSFHFSFODJBSNÂRVJOBT
    FNIPTUTOÄPMJOVYFDMPVE
    QSPWJEFST

    View full-size slide

  26. .ÂRVJOBTTÄP
    QSPWJTJPOBEBTDPNVN
    MJOVYCBTF%PDLFS&OHJOF

    View full-size slide

  27. /P049F8JOEPXT
    %PDLFS.BDIJOFPGFSFDF
    VNBJOUFSGBDFRVFBCTUSBJ
    BT"1*TEP7JSUVBMCPYF
    7.8BSF

    View full-size slide

  28. docker-machine create dev --driver virtualbox

    View full-size slide

  29. docker-machine start dev

    View full-size slide

  30. eval “$(docker-machine env dev)”

    View full-size slide

  31. %PDLFS

    $PNQPTF

    GPSNFSpH

    View full-size slide

  32. 'FSSBNFOUBEF
    PSRVFTUBÇÄPRVFQFSNJUF
    EFDMBSBSFTVCJSNÙMUJQMPT
    DPOUBJOFST

    View full-size slide

  33. &WJUBPUSBCBMIPEFSPEBS
    WÂSJPTEPDLFSSVOQBSB
    TVCJSUPEPTPTDPOUBJOFST
    OFDFTTÂSJPT

    View full-size slide

  34. 1 wordpress:
    2 image: wordpress
    3 links:
    4 - db:mysql
    5 ports:
    6 - 80:80
    7 working_dir: /var/www/html
    8 volumes:
    9 - .:/var/www/html/wp-content/themes/development
    10 db:
    11 image: mariadb
    12 environment:
    13 MYSQL_ROOT_PASSWORD: example
    docker-compose.yml
    /PNFEPDPOUBJOFS
    *NBHFN
    -JOLFOUSFDPOUBJOFST
    .BQFBNFOUPEFQPSUBT
    $PNQBSUJMIBNFOUPEFBSRVJWPT

    View full-size slide

  35. 1 python:
    2 build: ./Dockerfile

    3 volumes:
    4 - .:/data
    docker-compose.yml

    View full-size slide

  36. docker-compose up

    View full-size slide

  37. 0RVFFTUÄPGBMBOEPTPCSF

    View full-size slide

  38. Pontos positivos
    • Mesmo ambiente em dev e prod
    • Dependências facilmente atualizadas
    • Leve e rápido
    • Possibilidade de compor containers

    View full-size slide

  39. Pontos negativos
    • APIs mudam muito rápido
    • Conceito de containers é difícil de entender
    • Comandos muito extensos, difícil memorização

    View full-size slide

  40. Vagrant x Docker
    • Vagrant + Provisionamento é difícil de atualizar
    • Containers são bem mais leves e com boot mais rápido

    View full-size slide

  41. 1PSPOEFDPNFÇBS

    View full-size slide

  42. (FUUJOH4UBSUFE

    IUUQTEPDTEPDLFSDPNNBD
    IUUQTEPDTEPDLFSDPNXJOEPXT
    IUUQTEPDTEPDLFSDPNMJOVY

    View full-size slide

  43. %PDVNFOUBÇÄP

    IUUQTEPDTEPDLFSDPN

    View full-size slide

  44. $POUBJOFST
    DPN%PDLFS

    %BOJFM3PNFSP

    View full-size slide

  45. %PDLFS

    5PPMCPY
    IUUQTEPDLFSDPNQSPEVDUTEPDLFSUPPMCPY

    View full-size slide

  46. 5FNNBJTDPJTB

    View full-size slide

  47. Tutum Codeship
    DigitalOcean

    View full-size slide

  48. VALEU!
    vilar.cc/about

    View full-size slide