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

Docker Meetup Paris #1

Docker Meetup Paris #1

* Intro to Docker
* Installing Docker
* Basic Commands
* Demo: Simple deployment
* Questions

Victor Vieux

October 02, 2013
Tweet

More Decks by Victor Vieux

Other Decks in Technology

Transcript

  1. Docker Paris meetup #1 – 10/02/2013
    Victor Vieux, dotCloud Inc.
    @vieux

    View Slide

  2. Outline
    •  Intro to Docker
    •  Installing Docker
    •  Basic commands
    •  Demo: Simple deployment
    •  Questions

    View Slide

  3. Quick survey
    •  How many people have heard of Docker
    before this Meetup ?
    •  How many people have tried Docker ?
    •  How many people are using Docker in
    production ?

    View Slide

  4. Introduction to Docker

    View Slide

  5. Origins of Docker
    •  Docker is a rewrite of similar code that
    currently powers the dotCloud PaaS
    •  Original version written in Python (like
    dotCloud PaaS), now written in Go
    •  It’s a young project (~6 months), but with a
    huge community.

    View Slide

  6. Docker Timeline
    •  January 2013 Docker started as an internal project
    inside of dotCloud
    •  March 21, 2013 Solomon gives Docker lightning
    talk a PyCon US
    •  March 27, 2013 Docker 0.1 released to Public
    •  September 4, 2013 Docker merged into Openstack
    for the Havana release
    •  September 19, 2013 Partnership with Red Hat
    around OpenShift
    •  September 27, 2013 Docker 0.6.3 released

    View Slide

  7. In the first 6 months
    •  6000+ Github stars
    •  150+ Contributors
    •  50,000+ docker index pull
    •  100’s of projects built on top of Docker
    – UIs (DockerUI, Shipyard, Dockland…)
    – Open Source PaaS (DEIS, Flynn, Dokku…)
    – Continuous Deployment (Strider…)
    •  1700’s Dockerized applications on Github

    View Slide

  8. What is Docker ?
    “Docker is an open-source engine to
    easily create lightweight, portable,
    self-sufficient containers from any
    application. The same container that
    a developer builds and test on a
    laptop can run at scale, in production,
    on VMs, OpenStack cluster, public
    clouds and more.”

    View Slide

  9. How does Docker work ?
    •  LinuX Containers (LXC)
    •  Control Groups & Namespaces
    •  AUFS
    •  Client – Server with an HTTP API

    View Slide

  10. LinuX Containers (LCX)
    •  Let’s your run a Linux system within another
    Linux system
    •  A container is a group of processes on a
    Linux box, put together is an isolated
    environment
    •  From the inside, it looks like a VM
    •  From the outside, it looks like normal
    processes
    •  “chroot on steroids”

    View Slide

  11. Why Containers?
    •  Speed: Boots in seconds
    •  Footprint: 100-1000 containers on one
    machine. Small disk requirements

    View Slide

  12. Containers vs. VMs

    View Slide

  13. Control Groups & Namespaces
    Linux kernel feature to limit, account and
    isolate resource usage, such as:
    – CPU
    – Memory
    – Disk I/O

    View Slide

  14. AUFS
     
    •  File system that implements union mount.
     
     
     
    •  Supports Copy On Write (COW):
     
     
     
    # mount –t aufs –o br=/files1:/files2 none /files
     
     
     
    # mount –t aufs –o br=/tmp=rw:/bin=ro none /files
     
     

    View Slide

  15. Installing Docker

    View Slide

  16. Requirements
    •  Linux Kernel 3.8 or above
    •  AUFS
    •  LXC
    •  64-bit

    View Slide

  17. Installations
    •  Ubuntu Linux
    •  Binaries
    •  Using Vagrant
    More on: http://docs.docker.io/en/latest/installation

    View Slide

  18. Installation: Ubuntu Linux
    •  AUFS support
    $> sudo apt-get update
    $> sudo apt-get intall linux-image-extra-`uname –r`
    •  Add Docker repository
    $> sudo sh –c “curl https://get.docker.io/gpg | apt-key add -”
    $> sudo sh –c “echo deb http://get.docker.io/ubuntu docker \
    main > /etc/apt/sources.list.d/docker.list”
    •  Install
    $> sudo apt-get update
    $> sudo apt-get install lxc-docker

    View Slide

  19. Installation: Binaries
    •  Get the docker binary
    $> wget –output-document=docker https://get.docker.io/builds/\
    Linux/x86_64/docker-latest
    $> chmod +x docker
    •  Run the docker daemon
    $> sudo ./docker –d &
    •  Use your own system startup script
     

    View Slide

  20. Installation: Vagrant
    •  Clone the Docker repository
    $> git clone https://github.com/dotcloud/docker.git
    •  Startup the vagrant image
    $> vagrant up
     
    •  SSH into the image
    $> vagrant ssh
    •  Docker client works on Mac

    View Slide

  21. Basic  commands  

    View Slide

  22. Classic: hello world
    •  Get one base image (ubuntu, centos, busybox,…)
    $> docker pull ubuntu
    •  List images on your system
    $> docker images
     
     
    •  Print hello world
    $> docker run ubuntu:12.10 echo “hello world”
     

    View Slide

  23. Detached mode
    •  Run  in  Docker  using  the  detach  flag  (-­‐d)  
    $> docker run –d ubuntu sh –c “while true; do echo hello
    world; sleep 1; done”
    •  Get  container’s  id  
    $> docker ps
    •  A:ach  to  the  container  
    $> docker attach
     
    •  Stop/Start/Restart  the  container  
    $> docker stop
     

    View Slide

  24. Containers vs Images
    •  Remove a file from an image
    $> docker run busybox rm /etc/passwd
    •  The file is still there ??
    $> docker run busybox cat /etc/passwd
    •  Commit the newly created to an image
    $> docker ps –n=2 #get the container’s id
    $> docker commit vieux/broken-busybox
     
    •  The file is gone
    $> docker run vieux/broken-busybox cat /etc/passwd

    View Slide

  25. Public Index & Network
    •  Pull an apache image from the public index
    $> docker search apache
    $> docker pull creack/apache2
    •  Run the image and check the ports
    $> docker run –d creack/apache2
    $> docker ps
    •  Expose public ports
    $> docker run –d –p 8888:80 –p 4444:443 creack/apache2
    $> docker ps
     

    View Slide

  26. Creating your 1st app: the interactive way
    •  Using docker in interactive mode
    $> docker run –i –t ubuntu bash
    [email protected]:/#
    [email protected]:/# apt-get update
    […]
    [email protected]:/# apt-get install memcached
    […]
    [email protected]:/# exit
    •  Commit the image
    $> docker commit `docker ps –q –l` vieux/memcached
    •  Start the image
    $> docker run –d –p 11211 –u daemon vieux/memcached memcached

    View Slide

  27. Creating your 1st app: the boring way
    •  Multiple run / commit
    $> docker run ubuntu apt-get update
    $> $ID=(docker commit `docker ps –q –l`)
    $> docker run $ID apt-get install memcached
    $> docker commit `docker ps –q –l vieux/memcached
    •  Define default configuration at commit
    $> docker commit –run=‘{“Entrypoint”: [“memcached”]}’ […]
    •  Start the image
    $> docker run –d –p 11211 –u daemon vieux/memcached

    View Slide

  28. Creating your 1st app: the scripted way
    •  Write a Dockerfile
    # Memcached
    FROM ubuntu
    MAINTAINER Victor Vieux
    RUN apt-get update
    RUN apt-get install –y memcached
    ENTRYPOINT [“memcached”]
    USER daemon
    EXPOSE 11211
    •  Buid the image
    $> docker build –t=vieux/memcached .
    •  Start the image
    $> docker run –d vieux/memcached memcached

    View Slide

  29. Volumes and bind mounts
    •  Put your persistent data in a volume
    $> $ID=(docker run –d –v /var/lib/mysql vieux/mysql)
    •  So you can re use it in another container
    $> docker run –d –volumes-from=$ID vieux/mysql
     
    •  Bind mounts
    $> docker run –d –v /home/vv:/home
    •  Supports read only / read write
    $> docker run –d –v host/path:container/path:rw

    View Slide

  30. Other commands
    •  docker cp #copy a file from container to host
    •  docker diff #print container changes
    •  docker top #display running processes inside a container
    •  docker rm/rmi #delete container/image
    •  docker wait #wait until container stop and print exit code
    More on: http://docs.docker.io/en/latest/commandline/cli

    View Slide

  31. Demo:
    Simple deployment

    View Slide

  32. Local development
    •  App running in prod
    http://ks3100989.kimsufi.com:8080/
    •  Build local
     $> docker build –t=gcm .
    •  Test local
    $> docker run –p 49200:8080 gcm
     http://localhost:49200
    •  Change some files
    •  Rebuild & test
    $> docker build –t=gcm .
    $> docker run –p 49200:8080 gcm

    View Slide

  33. Push to prod
    •  Tag image in order to push it
    $> docker tag gcm ks3100989.kimsufi.com:5000/gcm
    •  Push image to local registry
    $> docker push ks3100989.kimsufi.com:5000/gcm
    •  On production server, download image
    $> docker pull ks3100989.kimsufi.com:5000/gcm
    •  Restart the container
    $> docker stop
    $> docker run –d –p 8080:8080

    View Slide

  34. Questions ?

    View Slide

  35. Thank you!
    @vieux

    View Slide