Docker, contain him, he his fast!

B13383dfb9b1b7c6bdde845aef0d5d83?s=47 Joel Wurtz
January 25, 2014

Docker, contain him, he his fast!

Slides for my talk at PHPBenelux 2014

B13383dfb9b1b7c6bdde845aef0d5d83?s=128

Joel Wurtz

January 25, 2014
Tweet

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. IN THE BEGINNING... Apache PHP Mysql

  4. NOWADAYS Apache, PHP, Mysql, Nginx, PostgreSQL, Redis, Memached, Elasticsearch, HHVM,

    RabbitMQ, ...
  5. 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
  6. HOW TO TEST A NEW TOOL? I want to try

    this incredibly new web stack
  7. IT BREAKS EVERYTHING ON MY LAPTOP Isolation is needed: Virtualization

  8. FINALLY THIS NEW TOOL DOESN'T WORK Go back to the

    old state: Pretty hard to do
  9. WE NEED TO REBUILD OUR OLD SYSTEM Automation tool: Chef,

    Puppet, Ansible, ...
  10. ONLY ONE TYPE OF SERVER

  11. FINALLY If you want to test a new tool you

    will be (in most case) discouraged by the amount of work needed.
  12. None
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. WHAT DOCKER BRINGS YOU Isolation Manage your infrastructure by versions

    Rollback? Just get back to the old version Failure at no cost
  20. 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)
  21. BUILD ONCE AND REALLY RUN EVERYWHERE 100% certitude (not 99.99%)!

  22. 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
  23. JUST FOR YOUR APPLICATIONS Only contains your application stack. System?

    We don't care.
  24. UNDER THE HOOD

  25. CONTAINERS Containers help Dev and Ops focus on their own

    specific problems and make communication easier by providing a normalized interface. PSR-DEVOPS
  26. 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
  27. 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)
  28. OTHER FEATURES Light & Fast: small footprint Resource isolation: limit

    cpu, memory, disk i/o usage
  29. EXISTING IMPLEMENTATIONS chroot LXC OpenVZ BSD Jails

  30. DOCKER A layer of simplicity over LXC complexity. Using container

    has never been so easy.
  31. THE THING TO KNOW A container only run one process

  32. HOW DO I DO FOR NGINX + PHP-FPM? Run a

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

    act like a proxy : Your best option boot2docker
  34. IMAGES An image is a version of your container

  35. CONTINUOUS INTEGRATION Do you like TravisCi?

  36. 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
  37. 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
  38. 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
  39. 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
  40. SUMMARY I have now have 3 differents environments on which

    i am testing my application
  41. 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
  42. DEMO

  43. WHITE-LABELING PROJECT Isolation and security Reproducibility

  44. PRIVATE CLOUD Openstack + Docker = <3

  45. GOING FURTHER Orchestration: Service discovery: docker-php CoreOs Shipyard Serf

  46. THANK YOU Twitter: http://docker.io @joelwurtz http://github.com/jolicode/joliCi