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.

Fc9eb764fbfae2be2e66da4f3ce62008?s=128

Sérgio Vilar

March 16, 2016
Tweet

Transcript

  1. FNBNCJFOUFTEFEFTFOWPMWJNFOUP &OGSFOUBOEPP%PDLFS

  2. 4ʡSHJP7JMBS 4PGUXBSF&OHJOFFS

  3. None
  4. 1BESPOJ[BÇÄPEPBNCJFOUFEF EFTFOWPMWJNFOUP

  5. None
  6. 7JSUVBMJ[BÇÄP

  7. 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
  8. Docker?

  9. &OHJOFRVFGBDJMJUBP EFTFOWPMWJNFOUPF EJTUSJCVJÇÄPEFXFCBQQT VTBOEPDPOUBJOFSTMJOVY

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

  11. 7. %PDLFS$POUBJOFST $POUBJOFSTTÄPJTPMBEPT
 NBTDPNQBSUJMIBNP40F
 CJOTMJCTRVBOEPDPOWFOJFOUF

  12. 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
  13. 7JSUVBMJ[BÇÄPFN$POUBJOFST Host OS (Linux) Docker Engine MySQL 
 (LXC Container)

    App Nginx
 (LXC Container) PHP-FPM
 (LXC Container) "NCJFOUF
 QBESPOJ[BEP
  14. 0RVFTÄP %PDLFS$POUBJOFST

  15. 4ÄPDPOUBJOFSTMJOVY JTPMBEPTDSJBEPTBQBSUJS EFVNBJNBHFN

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

  17. %PDLFS)VC
 IVCEPDLFSDPN

  18. docker pull phpunit/phpunit

  19. None
  20. $POTUSVJOEP TVBTQSÓQSJBT JNBHFOT

  21. 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
  22. $BEBJOTUSVÇÄP36/ BEJDJPOBVNBOPWB DBNBEBÁJNBHFN

  23. 2VBOUPNBJTDBNBEBT  NBJTFTQBÇPBJNBHFN PDVQBSÂ

  24. 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
  25. $BNBEBTFNDPNVNTÄP DPNQBSUJMIBEBTFOUSF DPOUBJOFST

  26. 3PEBOEP
 $POUBJOFST

  27. docker run --name meubanco mariadb

  28. DEMO

  29. %PDLFS
 .BDIJOF
 GPSNFSCPPUEPDLFS

  30. 'FSSBNFOUBRVFQFSNJUF DSJBSFHFSFODJBSNÂRVJOBT FNIPTUTOÄPMJOVYFDMPVE QSPWJEFST

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

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

  33. docker-machine create dev --driver virtualbox

  34. docker-machine start dev

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

  36. DEMO

  37. %PDLFS
 $PNQPTF
 GPSNFSpH

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

  39. &WJUBPUSBCBMIPEFSPEBS WÂSJPTEPDLFSSVOQBSB TVCJSUPEPTPTDPOUBJOFST OFDFTTÂSJPT

  40. 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
  41. 1 python: 2 build: ./Dockerfile
 3 volumes: 4 - .:/data

    docker-compose.yml
  42. docker-compose up

  43. DEMO

  44. 0RVFFTUÄPGBMBOEPTPCSF

  45. Pontos positivos • Mesmo ambiente em dev e prod •

    Dependências facilmente atualizadas • Leve e rápido • Possibilidade de compor containers
  46. Pontos negativos • APIs mudam muito rápido • Conceito de

    containers é difícil de entender • Comandos muito extensos, difícil memorização
  47. Vagrant x Docker • Vagrant + Provisionamento é difícil de

    atualizar • Containers são bem mais leves e com boot mais rápido
  48. 1PSPOEFDPNFÇBS

  49. (FUUJOH4UBSUFE
 IUUQTEPDTEPDLFSDPNNBD IUUQTEPDTEPDLFSDPNXJOEPXT IUUQTEPDTEPDLFSDPNMJOVY

  50. %PDVNFOUBÇÄP
 IUUQTEPDTEPDLFSDPN

  51. $POUBJOFST DPN%PDLFS
 %BOJFM3PNFSP

  52. %PDLFS
 5PPMCPY IUUQTEPDLFSDPNQSPEVDUTEPDLFSUPPMCPY

  53. ,JUFNBUJD

  54. 5FNNBJTDPJTB

  55. 5FN

  56. Tutum Codeship DigitalOcean

  57. VALEU! vilar.cc/about