Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to docker


Published on

Published in: Technology

Introduction to docker

  1. 1. Introduction to Docker @endhrk
  2. 2. Agenda ● What Is Docker ● How To Use Docker – How Do I Install Docker – How Do I Use Docker – How Do I Build containers – How Do I Terminate ● Important Docker terms ● Consisting Of Docker Engine – Lightweight – Portable – Packaging
  3. 3. What Is Docker ● Open platform ● For developers and system administrators ● To build, ship ,run applications
  4. 4. How To Use Docker ● Install ● Use ● Build ● Delete
  5. 5. How Do I Install Docker *may not be the latest Docker release **Install for Ubuntu 14.04 $ sudo apt-get -y install $ sudo ln -sf /usr/bin/ /usr/local/bin/docker $ sudo gpasswd -a $USER docker
  6. 6. How Do I Use Docker $ sudo start $ docker run -i -t ubuntu /bin/bash root@0f0bd22ce93e:/#
  7. 7. How Do I Build Containers ● Dockerfile FROM ubuntu:14.04 RUN apt-get -y install apache2 EXPOSE 80 CMD [“/usr/sbin/apache2ctl”, “-D”, “FOREGROUND”] $ docker build -t apache . $ docker run -d -P apache f254fc1aa31909783a26fb14f80d75ba128762b605604f95ef9a146de0ee46ed
  8. 8. How Do I Terminate ● Stop container ● Remove container ● Remove all images ● $ docker stop f254fc1aa319 $ docker rmi `docker images -q` $ docker rm f254fc1aa319
  9. 9. Important Docker Terms ● Docker image – Is Read-only template ● ex. contains an Ubuntu with Apache and applications – Is used to create Docker container – Provides simple way for delivery ● Docker registry – Holds images – Provides simple way to upload and download images – Has public and private ● Public is called Docker Hub ● Private Docker registry is provided by docker image at Docker Hub. ● Docker container – Is an isolated and secure application platform – Is created from a Docker image – Can be run, started, stopped, moved, deleted
  10. 10. Consisting Of Docker Engine ● Lightweight ● Portable ● Packaging
  11. 11. Consisting Of Docker Engine ● Lightweight ● Portable ● Packaging
  12. 12. Why Is Docker Lightweight ● Container virtualization ● Union file system
  13. 13. Why Is Docker Lightweight ● Container virtualization ● Union file system
  14. 14. What Is Container Virtualization ● Virtualization technology – Hardware virtualization (ex. VMware, Hyper-v) – Container virtualization (ex. Docker, OpenVZ)
  15. 15. What Are Difference Between Technologies Hardware virtualization Container virtualization What is virtualized Virtualized hardware environment Virtualized OS environment What can be put on Host Different OS Different Lib/Bin (kernel is shared) What is launched Launch OS Launch process How to access I/O Via Virtualized hardware Use directly limited resources
  16. 16. What Are Stacks Difference Between Technologies Hardware Hypervisor Bin/Libs MW MW MW App App App Kernel Bin/Libs Kernel Bin/Libs Kernel Virtual Hardware Virtual Hardware Virtual Hardware Hardware Linux kernel Bin/Libs Docker daemon MW MW App App Bin/Libs Bin/Libs Hardware virtualization Container virtualization
  17. 17. How Much Are Their Performance Difference CPU Memory fileio 0 sec 5 sec 10 sec 15 sec 20 sec 25 sec 30 sec 35 sec physical docker virtualbox * This benchmark was measured using sysbench
  18. 18. Components For Container Virtualization ● Isolation – Identify a set of processes – Isolate resources – Don't recognize each other processes ● Resource control – Limit the resources used * resource = process id, memory, cpu, disk space, network
  19. 19. How To Realize Container Virtualization ● Using kernel feature ● Isolation via namespace – PID namespace – Network namespace – UTS namespace (hostname etc.) – IPC namespace – Mount namespace ● Resource control via cgroups – Resource limiting – Prioritization process – Accounting using resources – Control groups
  20. 20. What Is Meant By Lightweight For Container ● Container virtualization – Launch faster ● launch only process. Kernel was already booted. – Use resources efficiently ● Kernel and memory are shared – Run process faster ● There is no overhead like hardware virtualization
  21. 21. Why Is Docker Lightweight ● Container virtualization ● Union file system
  22. 22. What Is Union File System ● Union file system is – Several filesystems to be mounted, appearing to be one filesystem ● Docker uses aufs – You can choose other option (ex. devicemapper
  23. 23. How Does Aufs Work 1.Mount a base image as read-only 2.Add read-write file system over read-only file system 3.Change some files and directories to top as read- write file system 4.It is committed 5.Save incremental files and directories in new image 6.Mount the image as read-only and add read-write file system on top
  24. 24. How Does Aufs Work
  25. 25. What Is Meant By Lightweight For Union File System Bin/Libs MW App Image Bin/Libs MW App Container1 shared MW App Container2 ● Owing to use of union file system – Not changed files are shared for each containers – Storage and memory spaces are saved – Faster deployment of containers shared MW App Container3 shared shared App Container4
  26. 26. Consisting Of Docker Engine ● Lightweight ● Portable ● Packaging
  27. 27. Why Is Docker Portable ● Run anywhere ● Simple way to take image to another environment ● Copy Incremental files only
  28. 28. Which Environment Can I Use ● Run anywhere – Any OS? ● ex. Linux, ?Mac OSX?, ?Windows? – Any Cloud ● ex. Google Cloud Platform, Amazon Web Services, SoftLayer – Any Physical Machine ● ex. Your PC, Server for production *You have to use Docker on Virtualbox if you use Mac OSX or Windows
  29. 29. How Can I Take the Image ● Simple way to take image to another environment – Docker Hub (like GitHub) ● Can set tag (version control) ● Easy to push image ● Easy to pull image ● Allow to access from anyone – Private registry ● Can limit access person who is not allowed ● Basic features are same as Docker Hub
  30. 30. What Does Docker Copy Bin/Libs MW App Bin/Libs MW App Diff Image Bin/Libs MW App Container Update Container Commit Diff Image Run Run Bin/Libs MW App Diff Container ● Save only changed files ● Push or pull just small increment files
  31. 31. What Is Meant By Portable ● Run anywhere ● Simple way to take image to another environment ● Copy Incremental files only
  32. 32. Consisting Of Docker Engine ● Lightweight ● Portable ● Packaging
  33. 33. What Is Packaged In Docker Image ● Docker image contains – Application – Middleware required by Application – Basic programs (like a OS) – Settings ● Application, Middleware, OS(Disk, Network) ● All of things for running Application
  34. 34. What Is Meant By Packaging ● Image contains all of things for running application ● Packaging realize – Portable and reliable application deployments – Rapid and efficient application delivery – Simplified application runtime environment – Coding explicit knowledge
  35. 35. Review ● How to use Docker ● Important docker terms ● Consisting of Docker Engine – Lightweight – Portable – Packaging
  36. 36. Thanks