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

Docker

 Docker

An introduction to docker. We’ll discuss what docker is and what it isn’t, comparing it to solutions you might be more familiar with (virtualbox, vmware, etc). Next we’ll see how docker can ease development and deployment of applications with its concept of containers.

http://2014.phpday.it/

Alexander

May 17, 2014
Tweet

More Decks by Alexander

Other Decks in Technology

Transcript

  1. View Slide

  2. asm89
    /
    @iam_asm89

    View Slide

  3. View Slide

  4. View Slide

  5. Dependencies

    View Slide

  6. ?

    View Slide

  7. ?

    View Slide

  8. ?

    View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. Deployment

    View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. View Slide

  18. View Slide

  19. View Slide

  20. View Slide

  21. Linux containers
    Run
    everywhere

    View Slide

  22. Linux containers
    Run
    everything

    View Slide

  23. View Slide

  24. What is
    a linux
    container?

    View Slide

  25. Lightweight VM
    ● Own process space
    ● Own network interface
    ● Can run stuff as root
    ● Can have its own /sbin/init
    “machine container”

    View Slide

  26. Lightweight VM
    ● Own process space
    ● Own network interface
    ● Can run stuff as root
    ● Can have its own /sbin/init
    “machine container”
    ● Not having its own /sbin/init
    ● Isolated processes
    ● Share kernel with the host
    “application container”
    Chroot on steroids

    View Slide

  27. VM vs Container

    View Slide

  28. $ ps aux | wc -l
    174
    $ docker run -it ubuntu bash
    [email protected]:/# ps aux
    USER PID %CPU %MEM VSZ RSS TTY STAT START
    TIME COMMAND
    root 1 4.0 0.0 18152 1856 ? Ss 23:05 0:00 bash
    root 9 0.0 0.0 15568 1148 ? R+ 23:05 0:00 ps aux

    View Slide

  29. Docker
    101

    View Slide

  30. $ sudo apt-get update
    $ sudo apt-get install docker.io
    $ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker

    View Slide

  31. $ docker pull ubuntu

    View Slide

  32. $ docker images | grep ubuntu
    ubuntu 13.10 5e019ab7bf6d 3 weeks ago 180 MB
    ubuntu saucy 5e019ab7bf6d 3 weeks ago 180 MB
    ubuntu precise 74fe38d11401 3 weeks ago 209.4 MB
    ubuntu 12.04 74fe38d11401 3 weeks ago 209.4 MB
    ubuntu 12.10 a7cf8ae4e998 3 weeks ago 171.2 MB
    ubuntu quantal a7cf8ae4e998 3 weeks ago 171.2 MB
    ubuntu 14.04 99ec81b80c55 3 weeks ago 266 MB
    ...

    View Slide

  33. $ docker run ubuntu echo “hello world”
    hello world

    View Slide

  34. Demo

    View Slide

  35. $ docker run -d ubuntu ping 127.0.0.1

    View Slide

  36. $ docker run -d ubuntu ping 127.0.0.1
    $ docker ps

    View Slide

  37. $ docker run -d ubuntu ping 127.0.0.1
    $ docker ps
    $ docker attach

    View Slide

  38. $ docker run -d ubuntu ping 127.0.0.1
    $ docker ps
    $ docker attach
    $ docker stop/start/restart

    View Slide

  39. Demo

    View Slide

  40. $ docker run ubuntu rm /etc/passwd

    View Slide

  41. $ docker run ubuntu rm /etc/passwd
    $ docker run ubuntu cat /etc/passwd
    root:x:0:0:root:/root:/bin/bash

    View Slide

  42. $ docker run ubuntu rm /etc/passwd
    $ docker run ubuntu cat /etc/passwd
    root:x:0:0:root:/root:/bin/bash

    $ docker ps -n=2

    View Slide

  43. $ docker run ubuntu rm /etc/passwd
    $ docker run ubuntu cat /etc/passwd
    root:x:0:0:root:/root:/bin/bash

    $ docker ps -n=2
    $ docker commit borked-ubuntu

    View Slide

  44. $ docker run ubuntu rm /etc/passwd
    $ docker run ubuntu cat /etc/passwd
    root:x:0:0:root:/root:/bin/bash

    $ docker ps -n=2
    $ docker commit borked-ubuntu
    $ docker run borked-ubuntu cat /etc/passwd
    cat: /etc/passwd: No such file or directory

    View Slide

  45. Demo

    View Slide

  46. Creating
    images

    View Slide

  47. Manually
    In container
    $ apt-get install php5-cli
    $ echo "phpday!';" > /index.php
    On host
    $ docker commit

    View Slide

  48. Manually
    In container
    $ apt-get install php5-cli
    $ echo "phpday!';" > /index.php
    On host
    $ docker commit
    FROM ubuntu
    RUN apt-get install -y php5-cli
    RUN echo "phpday!';" > /index.php
    EXPOSE 8000
    ENTRYPOINT ["php", "-S", ":8000"]
    Dockerfile

    View Slide

  49. Demo

    View Slide

  50. Registry

    View Slide

  51. View Slide

  52. Docker powered
    mini-Heroku in
    around 100 lines of
    Bash.

    View Slide

  53. $ git push dokku master

    View Slide

  54. View Slide

  55. PHP
    Ruby
    Nodejs
    Java
    Scala
    Go
    Perl
    ...

    View Slide

  56. $ wget -qO- | sudo DOKKU_TAG=v0.2.3 bash
    https://raw.github.com/progrium/dokku/v0.2.3/bootstrap.sh

    View Slide

  57. Demo

    View Slide

  58. Try it!

    View Slide

  59. #docker @ freenode
    http://docker.io

    View Slide

  60. Happy
    shipping!

    View Slide

  61. @iam_asm89
    https://joind.in/11309

    View Slide