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

DGW16 Docker

ProdOps
June 20, 2016

DGW16 Docker

Introduction to Docker on DevGeekWeek'16

ProdOps

June 20, 2016
Tweet

More Decks by ProdOps

Other Decks in Technology

Transcript

  1. Leading in IT Education .co.il www. static website user data

    web frontend queue analytics development environments qa servers customer data center public cloud production cluster Challenge ?
  2. Leading in IT Education .co.il www. cargo of cars cargo

    of stuff deployment manual labor Hand-loading a ship cost $5.86 per ton before 1956.
  3. Leading in IT Education .co.il www. After 1956, using containers,

    it cost ¢16 per ton to load a ship. Containerization greatly reduced the time to load and unload cargo. Malcom Purcell McLean "A ship earns money only when she is at sea".
  4. Leading in IT Education .co.il www. static website user data

    web frontend queue analytics development environments qa servers customer data center public cloud production cluster
  5. Leading in IT Education .co.il www. so, why containers? STANDARDIZATION

    … facilitate commoditization of formerly custom processes and help maximize compatibility, interoperability, safety, repeatability, and quality. - wikipedia
  6. Leading in IT Education .co.il www. > docker run busybox

    /bin/echo ‘Hello World!’ Hello World! hello world! image command to run output
  7. Leading in IT Education .co.il www. > docker run --tty

    --interactive busybox /bin/sh / # exit interactive container keep stdin attached image command to run
  8. Leading in IT Education .co.il www. $ uname -a #

    show kernel/linux version $ pwd # show current directory $ ls # show files in directory $ whoami # what is my user name $ id # what is my user id $ ps # what processes are running $ hostname # what is the server hostname $ ifconfig # network interface list $ netstat # network activity $ netstat -r # routing table $ mount # mounted file systems inspecting a linux environment
  9. Leading in IT Education .co.il www. > docker run -t

    -i -e PS1='\u@\h:\w# ' busybox /bin/sh root@abcdef:/# exit > container environment environment variable
  10. Leading in IT Education .co.il www. > docker run -ti

    busybox \ /bin/sh -c 'while true; do date; sleep 1; done' Sun Mar 23 18:57:17 IST 2015 Sun Mar 23 18:57:18 IST 2015 Sun Mar 23 18:57:19 IST 2015 Sun Mar 23 18:57:20 IST 2015 Sun Mar 23 18:57:21 IST 2015 ^C docker clock
  11. Leading in IT Education .co.il www. > docker run -d

    busybox \ /bin/sh -c 'while true; do date; sleep 1; done' e04e6a90bd09723fcda724ecd9392434992d7d0fd335bb465cd5f618570ee68e daemon clock! Hey! Where is the REAL output?
  12. Leading in IT Education .co.il www. > docker ps >

    docker top container_name_or_id > docker logs container_name_or_id > docker stop container_name_or_id > docker start container_name_or_id > docker rm container_name_or_id running containers CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d40ad71102b8 busybox:latest /bin/sh -c 'while tr 2 minutes ago Up 2 minutes berserk_hopper
  13. Leading in IT Education .co.il www. > docker inspect container_name

    # filtering a single property (using GO text/template) > docker inspect -f '{{ .NetworkSettings.IPAddress }}' cont_name container metadata
  14. Leading in IT Education .co.il www. > docker run -d

    busybox \ nc -ll -p 80 -e /bin/echo -e "HTTP/1.1 200 OK\n\nHello World.\n" 00ac7444f87e797d1a5e6cdd2eb8f916e7fefddcaa9d751551719fe49e5c9732 > docker inspect `docker ps -ql` | grep IPAddress "IPAddress": "172.17.0.2", > curl http://<ip_address> Hello World. a hello-world web server
  15. Leading in IT Education .co.il www. containers : what we

    learned so far ✓ running commands in a container ✓ starting interactive containers ✓ namespace separation ✓ containers with daemons ✓ inspecting live containers ✓ container metadata ✓ docker bridge networking
  16. Leading in IT Education .co.il www. en.wikipedia.org/wiki/SS_Ideal_X on April 26,

    1956 the Ideal X carried 58 containers from Port Newark, New Jersey, to Port of Houston, Texas, where 58 trucks were waiting to be loaded with the containers.
  17. Leading in IT Education .co.il www. > docker run -ti

    busybox /bin/sh / # cat > bin/server.sh #!/bin/sh PATH=/bin:/usr/bin nc -ll -p 80 -e echo -e "HTTP/1.1 200 OK\n\nI am very FAST!" ^D / # chmod +x bin/server.sh / # exit modifying containers
  18. Leading in IT Education .co.il www. > docker ps --latest

    > docker diff container_name A /.ash_history C /bin A /bin/server.sh what changed?
  19. Leading in IT Education .co.il www. container commit > docker

    commit -a ‘Evgeny Zislis <[email protected]>’ \ abcde123 haws/webserver 96e632d705113241816462ba9c7e94451384a505613dff64af192daf7bc78efb Hey! What is this?
  20. Leading in IT Education .co.il www. > docker images >

    docker search mongodb > docker pull mongodb/mongodb:latest > docker run -d mongodb/mongodb using images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE busybox latest a9eb17255234 5 days ago 2.433 MB ubuntu 14.04 99ec81b80c55 4 weeks ago 266 MB
  21. Leading in IT Education .co.il www. # server.sh #!/bin/sh PATH=/bin:/usr/bin

    nc -ll -p 80 -e echo -e "HTTP/1.1 200 OK\n\nI am very FAST!" # Dockerfile FROM busybox:latest ADD server.sh bin/server.sh ENTRYPOINT bin/server.sh > chmod 0750 server.sh && docker build -t haws/webserver . build an image
  22. Leading in IT Education .co.il www. tags for images >

    docker tag webserverNEW webserver > docker login user: haws pass: verysecret mail: [email protected] > docker push haws/webserverNEW
  23. Leading in IT Education .co.il www. Dockerfile instructions http://docs.docker.com/reference/builder/ FROM

    image:tag MAINTAINER Haws DevOpsIL <[email protected]> RUN command # runs it in /bin/sh -c ‘command’ RUN [ “exec”, “param”, “param” ] CMD command # or CMD [ “exec”, “param”, “param” ] ENTRYPOINT command # or ENTRYPOINT [ “exec”, “param” ]
  24. Leading in IT Education .co.il www. ENV key value ADD

    src dst # src is file, archive, or url (http://) COPY src dst USER someone WORKDIR somewhere Dockerfile instructions
  25. Leading in IT Education .co.il www. ✓ commit changed containers

    ✓ inspect difference made to container ✓ searching for community images ✓ docker image pulling and pushing ✓ building images using Dockerfiles ✓ injecting files into images with ADD images : what we learned so far
  26. Leading in IT Education .co.il www. Port of Shanghai how

    many TEUs it handled in 2014? how many ships handled?
  27. Leading in IT Education .co.il www. Port of Shanghai 35.29

    million TEU in 2014 busiest container port for the fifth consecutive year. handling more than 50,000 ships annually
  28. Leading in IT Education .co.il www. Thank you! www.devops.co.il We

    invite you to join Operations Israel Facebook group on on.fb.me/Ops-IL we are hiring at [email protected]