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. ?

  2. ?

  3. ?

  4. Lightweight VM • Own process space • Own network interface

    • Can run stuff as root • Can have its own /sbin/init “machine container”
  5. 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
  6. $ 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
  7. $ sudo apt-get update $ sudo apt-get install docker.io $

    sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
  8. $ 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 ...
  9. $ docker run -d ubuntu ping 127.0.0.1 $ docker ps

    $ docker attach <container_id>
  10. $ docker run -d ubuntu ping 127.0.0.1 $ docker ps

    $ docker attach <container_id> $ docker stop/start/restart <container_id>
  11. $ docker run ubuntu rm /etc/passwd $ docker run ubuntu

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

    cat /etc/passwd root:x:0:0:root:/root:/bin/bash … $ docker ps -n=2
  13. $ 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 <container_id> borked-ubuntu
  14. $ 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 <container_id> borked-ubuntu $ docker run borked-ubuntu cat /etc/passwd cat: /etc/passwd: No such file or directory
  15. Manually In container $ apt-get install php5-cli $ echo "<?php

    echo 'hello phpday!';" > /index.php On host $ docker commit <id> <name>
  16. Manually In container $ apt-get install php5-cli $ echo "<?php

    echo 'hello phpday!';" > /index.php On host $ docker commit <id> <name> FROM ubuntu RUN apt-get install -y php5-cli RUN echo "<?php echo 'hello phpday!';" > /index.php EXPOSE 8000 ENTRYPOINT ["php", "-S", ":8000"] Dockerfile