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. asm89
    /
    @iam_asm89

    View full-size slide

  2. Dependencies

    View full-size slide

  3. Linux containers
    Run
    everywhere

    View full-size slide

  4. Linux containers
    Run
    everything

    View full-size slide

  5. What is
    a linux
    container?

    View full-size slide

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

    View full-size slide

  7. 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 full-size slide

  8. VM vs Container

    View full-size slide

  9. $ ps aux | wc -l
    174
    $ docker run -it ubuntu bash
    root@86f8213d57e0:/# 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 full-size slide

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

    View full-size slide

  11. $ docker pull ubuntu

    View full-size slide

  12. $ 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 full-size slide

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

    View full-size slide

  14. $ docker run -d ubuntu ping 127.0.0.1

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  18. $ docker run ubuntu rm /etc/passwd

    View full-size slide

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

    View full-size slide

  20. $ 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 full-size slide

  21. $ 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 full-size slide

  22. $ 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 full-size slide

  23. Creating
    images

    View full-size slide

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

    View full-size slide

  25. 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 full-size slide

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

    View full-size slide

  27. $ git push dokku master

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  31. Happy
    shipping!

    View full-size slide

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

    View full-size slide