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

Docker, contain him, he his fast!

Joel Wurtz
January 25, 2014

Docker, contain him, he his fast!

Slides for my talk at PHPBenelux 2014

Joel Wurtz

January 25, 2014
Tweet

Other Decks in Programming

Transcript

  1. DOCKER CONTAIN HIM, HE IS FAST! Docker, contain him, he

    his fast! – PHPBenelux 2014 – @joelwurtz – JoliCode
  2. HELLO Joel, a man from cheese country Developer, consultant for

    Try to make developers environments better Use Chef for about 2 years Now, a hipster fan of Docker JoliCode
  3. WHAT IS THE MAIN GOAL OF YOUR PHP APPLICATION? Manipulate

    data through a web interface (or api) Your client or buisness doesn't care about what is behind
  4. HOW TO TEST A NEW TOOL? I want to try

    this incredibly new web stack
  5. FINALLY If you want to test a new tool you

    will be (in most case) discouraged by the amount of work needed.
  6. THE DOCKER WAY Running your application $ d o c

    k e r r u n m y - a p p l i c a t i o n
  7. THE DOCKER WAY Testing php 5.5? $ d o c

    k e r r u n m y - a p p l i c a t i o n - p h p 5 5
  8. THE DOCKER WAY It works! $ d o c k

    e r c o m m i t m y - a p p l i c a t i o n - p h p 5 5 m y - a p p l i c a t i o n $ d o c k e r r u n m y - a p p l i c a t i o n
  9. THE DOCKER WAY It does not work! $ d o

    c k e r r u n m y - a p p l i c a t i o n
  10. THE DOCKER WAY Compare? Run twice your application! $ d

    o c k e r r u n m y - a p p l i c a t i o n $ d o c k e r r u n - p 8 0 8 1 m y - a p p l i c a t i o n - p h p 5 5
  11. THINK YOU INFRASTRUCTURE AS A SCM (GIT) REPOSITORY Commit the

    change Push your changes Pull the changes on another location Tag a version of your work $ d o c k e r c o m m i t m y - a p p l i c a t i o n $ d o c k e r p u s h m y - a p p l i c a t i o n $ d o c k e r p u l l m y - a p p l i c a t i o n $ d o c k e r t a g m y - a p p l i c a t i o n v 1 . 0
  12. WHAT DOCKER BRINGS YOU Isolation Manage your infrastructure by versions

    Rollback? Just get back to the old version Failure at no cost
  13. Dev: "It works on my machine, just not on the

    server." Me: "Ok, backup your mail. We're putting your laptop into production." — Oisin Grehan (x0n)
  14. FAST? $ t i m e s u d o

    d o c k e r r u n u b u n t u e c h o " h e l l o w o r l d " h e l l o w o r l d r e a l 0 m 0 . 2 4 3 s
  15. CONTAINERS Containers help Dev and Ops focus on their own

    specific problems and make communication easier by providing a normalized interface. PSR-DEVOPS
  16. CONTAINER: THE INSIDE (DEVELOPER) PART Look like a VM A

    container is a group of package in a isolated environment Do what the hell you want, this is your playground
  17. CONTAINER: THE OUTSIDE (OPERATIONAL) PART Look like processes Run on

    every Linux host (for LXC) Expose metadatas to know how to reach him (ports and commands)
  18. HOW DO I DO FOR NGINX + PHP-FPM? Run a

    service manager process: Supervisord
  19. NOT ON AN LINUX OS? Use a virtual machine to

    act like a proxy : Your best option boot2docker
  20. CREATE AN IMAGE: DOCKERFILE A php 5.3 image F R

    O M u b u n t u M A I N T A I N E R J o e l W u r t z # I n s t a l l d e p s R U N a p t - g e t i n s t a l l - y p h p 5 - c l i g i t # A d d m y p r o j e c t A D D . / p r o j e c t W O R K D I R / p r o j e c t
  21. CREATE AN IMAGE: DOCKERFILE A php 5.4 image F R

    O M u b u n t u M A I N T A I N E R J o e l W u r t z # A d d i n g p h p 5 . 4 r e p o R U N a p t - g e t u p d a t e & & a p t - g e t i n s t a l l - y p y t h o n - s o f t w a r e - p r o p e r t i R U N a d d - a p t - r e p o s i t o r y p p a : o n d r e j / p h p 5 - o l d s t a b l e & & a p t - g e t u p d a t # I n s t a l l d e p s R U N a p t - g e t i n s t a l l - y p h p 5 - c l i g i t # A d d m y p r o j e c t A D D . / p r o j e c t W O R K D I R / p r o j e c t
  22. CREATE AN IMAGE: DOCKERFILE A php 5.5 image F R

    O M u b u n t u M A I N T A I N E R J o e l W u r t z # A d d i n g p h p 5 . 5 r e p o R U N a p t - g e t u p d a t e & & a p t - g e t i n s t a l l - y p y t h o n - s o f t w a r e - p r o p e r t i R U N a d d - a p t - r e p o s i t o r y p p a : o n d r e j / p h p 5 & & a p t - g e t u p d a t e # I n s t a l l d e p s R U N a p t - g e t i n s t a l l - y p h p 5 - c l i g i t # A d d m y p r o j e c t A D D . / p r o j e c t W O R K D I R / p r o j e c t
  23. BUILD AND RUNNING YOUR IMAGES $ c p p h

    p 5 3 / D o c k e r f i l e . / & & d o c k e r b u i l d - t p h p 5 3 . $ c p p h p 5 4 / D o c k e r f i l e . / & & d o c k e r b u i l d - t p h p 5 4 . $ c p p h p 5 5 / D o c k e r f i l e . / & & d o c k e r b u i l d - t p h p 5 5 . $ d o c k e r r u n p h p 5 3 . / v e n d o r / b i n / p h p u n i t . . . / / y o u r t e s t s o n a p h p 5 . 3 $ d o c k e r r u n p h p 5 4 . / v e n d o r / b i n / p h p u n i t . . . / / y o u r t e s t s o n a p h p 5 . 4 $ d o c k e r r u n p h p 5 5 . / v e n d o r / b i n / p h p u n i t . . . / / y o u r t e s t s o n a p h p 5 . 5
  24. JOLICI TravisCi on your local computer with ease. Read your

    .travis.yml Create multiple Docker environnments (by creating Dockerfile) Run tests on your local computer