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

Building applications with Docker

Building applications with Docker

Toon Verwerft

November 27, 2015
Tweet

More Decks by Toon Verwerft

Other Decks in Programming

Transcript

  1. Problem:  code  from  DEV  to  PRD manual  setup (-­‐) nearly

     impossible  to  replicate  environments scripted  setup (+) +/-­‐ easy  to  replicate  environments (-­‐) knowlegderequired  about  what  is  inside  to   create  the  scripts containers (+) very  easy  to  replicate  (just  drop  it  into  place) (+) no  knowlegderequired  about  what  is  inside
  2. Build: #  docker build  -­‐t  trescst/phprodemo . Ship:   #

     docker push  trescst/phprodemo Run:   #  docker run  -­‐d  trescst/phprodemo
  3. 2  Dependencies • Explicitly declare  and  isolate  dependencies • Composer

     json +  lock  file • Bower  /  NPM  /  Bundle
  4. 3  Config • Store  config in  the  environment  variables •

    Never  group  configuration  in  “environments” • Each  env var is  independently  managed  for  each  deploy • Easy  upscaling
  5. 6  Process • Execute  the  app  as  one  or  more

     stateless  processes • Share  nothing • Data  must  be  stored  in  statefull backing  services
  6. 7.  Port  binding • Include  an  HTTP  server • Export

     services  via  port  binding • Add  a  routing  layer  for  mapping  the  port  to  a  subdomain • The  services  can  communicate  over  containers  by  port
  7. 8  Concurrency • Scale  out  via  the  process  model •

    Nothing  is  shared • Reliable  and  easy
  8. 9  Disposability • All  processes  can  be  stopped  /  started

     at  any  time. • Minimum  startup  time • Gracefull shutdown  in  SIGTERM • Maximum  robustness • Fast  deploys
  9. 10  Dev/prod  parity • Keep  development,  staging,  and  production  as

     similar  as  possible Traditional  app Twelve-­‐factor  app Time  between  deploys Weeks Hours Code  authors  vs  code  deployes Different  people Same  people Dev  vs  production  environments Divergent As  similar  as  possible
  10. 11  Logs • Treat  logs  as  event  streams • Always

     send  logs  to  the  output  stream • Never  concern  about  storage  of  the  output • Storage  is  handled  by  the  executing  environment.