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

Docker 101 - From Development to Production and back

Docker 101 - From Development to Production and back

Presented at TYPO3 Developer Days 2015

Dmitri Pisarev

July 16, 2015
Tweet

More Decks by Dmitri Pisarev

Other Decks in Programming

Transcript

  1. Work and study in — first independant Christian Theological University

    in Russia Worked with TYPO3 since 2006 One year ago first installed Neos... And loved it! Neos contributor since then SFI.ru
  2. Extremly lightweight VM? Almost. At least it feels like one

    Virtual Machines Containers Way less fat here!
  3. FreeBSD jails on steroids? Yes, but we had that years

    ago... n a m e s p a c e s isolation c g r o u p s resource control l i b c o n t a i n e r Docker container format U n i o n F S fast copy-on-write filesystem
  4. What problems does it solve? 1. Setup development environments in

    minutes 2. Have identical environment in production and development 3. Freedom to try new things without worrying about infrastructure
  5. Container Container is an isolated and secure application platform, that

    holds everything that is needed for an application to run
  6. Join the session now! Stuff to expect: Install the thing

    Learn the basic usage Going to production And much more!
  7. ...where we le off Agenda: Installation Managing data in containers

    Orchestration with Docker Compose Going to production
  8. It just works. Installation on Linux w g e t

    ­ q O ­ h t t p s : / / g e t . d o c k e r . c o m / | s h
  9. Installation on Mac/Windows “All hope abandon ye who enter here”

    ~Dante Alighieri, 1321AD You need boot2docker VM Use OSX or Windows installer Try without host volumes first Be ready for trouble! http://files.t3dd15.typo3.org/
  10. Create and start a container d o c k e

    r r u n ­ i ­ t b u s y b o x s h
  11. The versioned filesystem in Docker is based on layers. They're

    like git commits or changesets for filesystems. Layered filesystem
  12. Filesystem mounts outside of UFS. Can even be mounted from

    host OS. Data volumes / v a r / l i b / d o c k e r / v o l u m e s / f e 0 4 a 9 4 d f a a d 3 d 9 e f a 9 9 c 8 1 b d 7 9 a 4 2 b 3 8 3 b 5 5 1 7 1 . . .
  13. Data-only containers in practice d b d a t a

    : i m a g e : b u s y b o x : l a t e s t c o m m a n d : e c h o d b d a t a v o l u m e s : ­ / v a r / l i b / m y s q l w e b d a t a : i m a g e : b u s y b o x : l a t e s t c o m m a n d : e c h o w e b d a t a v o l u m e s : ­ d a t a : / d a t a
  14. Good old mySQL database d b : i m a

    g e : m i l l i o n 1 2 / m a r i a d b : l a t e s t p o r t s : ­ 3 3 0 6 v o l u m e s _ f r o m : ­ d b d a t a e n v i r o n m e n t : M A R I A D B _ P A S S : p a s s r e s t a r t : a l w a y s
  15. Web container with Neos demo site w e b :

    i m a g e : m i l l i o n 1 2 / t y p o 3 ­ n e o s p o r t s : ­ ' 8 0 ' l i n k s : ­ d b : d b v o l u m e s _ f r o m : ­ w e b d a t a e n v i r o n m e n t : V I R T U A L _ H O S T : ' n e o s m . d e v , d e v . n e o s m . d e v ' T 3 A P P _ N A M E : ' n e o s m . d e v ' T 3 A P P _ N E O S _ S I T E _ P A C K A G E : ' T Y P O 3 . N e o s D e m o T y p o 3 O r g ' r e s t a r t : a l w a y s
  16. SSH container s s h : i m a g

    e : m i l l i o n 1 2 / p h p ­ a p p ­ s s h p o r t s : ­ ' 2 2 ' l i n k s : ­ d b : d b ­ w e b : w e b v o l u m e s _ f r o m : ­ w e b d a t a ­ d b d a t a e n v i r o n m e n t : I M P O R T _ G I T H U B _ P U B _ K E Y S : d i m a i p r e s t a r t : a l w a y s
  17. Redis in a few lines of code r e d

    i s : i m a g e : r e d i s
  18. Nginx reverse proxy Internet Users Host machine LISTEN 0.0.0.0:80 Reverse

    proxy Web container Storage container MySQL Nginx php­fpm Neos proxypass
  19. docker-gen https://github.com/jwilder/docker-gen Generate any sorts of configs based on data

    from running docker containers Reverse-proxy configs SSH config file Whatever you like!
  20. Deploying containers 1. Merge change to master branch on Github

    2. Image is automatically rebuilt on Docker Hub 3. Pull new image, run it in parallel with the old one, test 4. Redirect traffic to new container, stop the old one 5. Rollback if things go wrong Great for big infrastructure changes, but slow for code-only deploys
  21. Hybrid deploy For small code changes: 1. Merge change to

    master branch on Github 2. CI tool of choice tests the build 3. Surf deploys code changes via SSH container And for big ones do full container re-deploy