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

Docker Introduction

Docker Introduction

An introductory presentation about Docker and its benefits.

Presented (in some variation) at:
* http://www.meetup.com/Docker-Tel-Aviv/events/174016622/
* http://www.meetup.com/Docker-Tel-Aviv/events/221108613/

ProdOps

May 19, 2014
Tweet

More Decks by ProdOps

Other Decks in Technology

Transcript

  1. 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".
  2. static website user data web frontend queue analytics development environments

    qa servers customer data center public cloud production cluster
  3. so, why containers? STANDARDIZATION … facilitate commoditization of formerly custom

    processes and help maximize compatibility, interoperability, safety, repeatability, and quality. - wikipedia
  4. > docker run --tty --interactive busybox /bin/sh / # exit

    interactive container keep stdin attached image command to run
  5. $ 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
  6. > docker run -t -i -e PS1='\u@\h:\w# ' busybox /bin/sh

    root@abcdef:/# exit > container environment environment variable
  7. > 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
  8. > docker run -d busybox \ /bin/sh -c 'while true;

    do date; sleep 1; done' e04e6a90bd09723fcda724ecd9392434992d7d0fd335bb465cd5f618570ee68e daemon clock! Hey! Where is the REAL output?
  9. > 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
  10. > docker inspect container_name # filtering a single property (using

    GO text/template) > docker inspect -f '{{ .NetworkSettings.IPAddress }}' cont_name container metadata dvps.me/docker-ws-cheat
  11. > 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
  12. 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
  13. 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.
  14. > 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
  15. > docker ps --latest > docker diff container_name A /.ash_history

    C /bin A /bin/server.sh # now run 3 containers with server.sh in parallel ... what changed?
  16. container commit > docker commit -a ‘Evgeny Zislis <[email protected]>’ \

    abcde123 haws/webserver 96e632d705113241816462ba9c7e94451384a505613dff64af192daf7bc78efb Hey! What is this?
  17. > 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
  18. # 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
  19. tags for images > docker tag webserverNEW webserver > docker

    login user: haws pass: verysecret mail: [email protected] > docker push haws/webserverNEW
  20. Dockerfile instructions http://docs.docker.com/reference/builder/ FROM image:tag MAINTAINER Evgeny Zislis <[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” ]
  21. ENV key value ADD src dst # src is file,

    archive, or url (http://) COPY src dst USER someone WORKDIR somewhere Dockerfile instructions cont.
  22. ✓ 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
  23. port of Shanghai 35.29 million TEU in 2014 busiest container

    port for the fifth consecutive year. handling more than 50,000 ships annually
  24. We invite you to join Operations Israel Facebook group on

    on.fb.me/Ops-IL link to slides: dvps.me/docker-intro Thank you! www.devops.co.il