Introduction to Containers
OR
How containers are changing the development & deployment story
across the software industry?
Agenda
● Linux containers
● Docker
● Kubernetes
● Development
● Deployment
● Microservices
Popularity of Containers
Virtualization
● Virtualization was around since decades
● But it got popular only in 2000s
● Lack of interest from hardware vendors
● Chip manufacturers saw the market opportunity
● Club that with cheapest OS platform adding support
Containers
● First available in Solaris and BSD
● Came to Linux somewhat later
● Docker made them really easy
● In a way, Linux and Docker made them popular
Linux Containers
Linux Containers
● Linux Kernel provides cgroups and namespaces
● cgroups help limit the resource consumption without a VM
● namespaces help completely isolate the process
● Combination of these two helps create containers
● Containers have been around since a long time
● Google says it runs everything in containers since decade+
Containers vs. VMs
Containers
● Use kernel of the host
● Contains only application binaries
and dependencies
● Lesser attack surface
● Can be spun up and ready to use in
milliseconds
● Container images are generally of
smaller size (in MBs)
Virtual Machines
● Have a kernel of their own
● Contains entire OS along with
application binaries and deps
● Higher attack surface
● Takes seconds or minutes before
being fully usable
● ISOs are generally more than 1 GiB
in size
Docker
Docker
● Started out as “dotCloud” PaaS company
● Made the containers and related things easy-to-use
● De facto container runtime for a long time
● Now a tool to build images, manage containers, orchestrate, etc.
● Open-source project contributed to by many in the industry
● Open-source now under “Moby Project”
Docker commands
● docker build -t myimage .
● docker pull fedora
● docker run -it fedora /bin/bash
● docker run -d -p 80:80 webserver
● docker stop <container-name>
● docker rm <container-name>
● docker rmi webserver
Why container orchestration?
● Say you have a web app with a database
● You’d want a container to be able to reliably talk with the other
● You’d want to have multiple replicas running
● You’d want to load balance it
● You’d want to distribute them across different systems
● One instance of some container shouldn’t take entire app down
Kubernetes (k8s)
Kubernetes (k8s)
● Started at Google and later open-sourced
● Most popular container orchestration tool
● Orchestration tool helps run containers in production
● Code contributions from most major organizations
● Very nice community
● Distributions for cloud, hybrid and on-prem deployments
● minikube for developers
Kubernetes Features
● Groups containers into pods
● Container auto-scaling
● Provides basic load balancing OOTB
● Canary deployments
● Health checks
● Documentation
Kubernetes Distributions
● Google Kubernetes Engine
● Amazon ECS
● CoreOS Tectonic
● OpenShift by Red Hat
● StackPoint
● … much more!
Development & Deployment
using Containers
Development with Containers
● Pack binaries and artifacts in the container image
● Expose required functionality/ports of container
● Take the same image and run a container anywhere*
● Overruled “works on my laptop” argument to a great extent
● One container supposed to do only one thing (UNIX philosophy)
* physical/virtual machine, any distro, any cloud
Developer workflow
● Every dev is working on their fork of the code
● Before merging into main repo, it goes through automated tests
● Tests happen on environment similar to production
● Container images are created, tagged and pushed
● Quick feedback loop on the tests
● Also called Continuous Integration (CI of CI/CD)
● Great piece written by Martin Fowler
Deployment with Containers
● Automation FTW but one of the most critical part
● Ops teams deploy code multiple time a day
● Inter-container communication has to be smooth
● Blue-Green deployments becoming popular
● Rollback in case something blows up
● All these is easier said than done
Microservices Architecture
Monoliths
● Single WAR file that runs everything
● Seems perfect initially till the time it becomes huge
● CI/CD can take long time as size increases
● Scaling can become an issue
● In short all issues you can imagine related with larger size
Microservices
● Break service down into pieces: database, API, front-end, etc.
● Specialized frameworks can be used for tasks
● Individual services can be scaled up/down
● APIs can be reused by other services
Containers
are not
THE solution
Tools
● Git for version controlling the code
● Jenkins, Travis for CI
● Docker, Buildah to create containers
● OpenShift for deployment and built-in CI/CD mechanism
● Elastic, Logstash, Kibana for logging aggregation
● Prometheus, Zabbix for monitoring
● … much more!
Learn more!
Join these and more
communities to learn and/or
share!
● Kubernetes Ahmedabad
● Docker Ahmedabad
● Ansible Ahmedabad
● DigitalOcean Ahmedabad
About Me
● Engineer @ Red Hat
● Love building tech
communities, sharing
knowledge and organizing
+ speaking at meetups
● Twitter: @dharm1t
Web: dharmitshah.com
Resources
● Google Borg
● Continuous Integration - Martin Fowler (ThoughtWorks)
● Continuous Deployment - Viktor Farcic (Cloudbees)
● Kubernetes Documentation
● Docker
● Buildah
● OpenShift by Red Hat
● All Kubernetes distributions
● Containers are Linux

Introduction to Containers

  • 1.
  • 2.
    OR How containers arechanging the development & deployment story across the software industry?
  • 3.
    Agenda ● Linux containers ●Docker ● Kubernetes ● Development ● Deployment ● Microservices
  • 4.
  • 5.
    Virtualization ● Virtualization wasaround since decades ● But it got popular only in 2000s ● Lack of interest from hardware vendors ● Chip manufacturers saw the market opportunity ● Club that with cheapest OS platform adding support
  • 6.
    Containers ● First availablein Solaris and BSD ● Came to Linux somewhat later ● Docker made them really easy ● In a way, Linux and Docker made them popular
  • 8.
  • 9.
    Linux Containers ● LinuxKernel provides cgroups and namespaces ● cgroups help limit the resource consumption without a VM ● namespaces help completely isolate the process ● Combination of these two helps create containers ● Containers have been around since a long time ● Google says it runs everything in containers since decade+
  • 10.
    Containers vs. VMs Containers ●Use kernel of the host ● Contains only application binaries and dependencies ● Lesser attack surface ● Can be spun up and ready to use in milliseconds ● Container images are generally of smaller size (in MBs) Virtual Machines ● Have a kernel of their own ● Contains entire OS along with application binaries and deps ● Higher attack surface ● Takes seconds or minutes before being fully usable ● ISOs are generally more than 1 GiB in size
  • 11.
  • 12.
    Docker ● Started outas “dotCloud” PaaS company ● Made the containers and related things easy-to-use ● De facto container runtime for a long time ● Now a tool to build images, manage containers, orchestrate, etc. ● Open-source project contributed to by many in the industry ● Open-source now under “Moby Project”
  • 13.
    Docker commands ● dockerbuild -t myimage . ● docker pull fedora ● docker run -it fedora /bin/bash ● docker run -d -p 80:80 webserver ● docker stop <container-name> ● docker rm <container-name> ● docker rmi webserver
  • 14.
    Why container orchestration? ●Say you have a web app with a database ● You’d want a container to be able to reliably talk with the other ● You’d want to have multiple replicas running ● You’d want to load balance it ● You’d want to distribute them across different systems ● One instance of some container shouldn’t take entire app down
  • 15.
  • 16.
    Kubernetes (k8s) ● Startedat Google and later open-sourced ● Most popular container orchestration tool ● Orchestration tool helps run containers in production ● Code contributions from most major organizations ● Very nice community ● Distributions for cloud, hybrid and on-prem deployments ● minikube for developers
  • 17.
    Kubernetes Features ● Groupscontainers into pods ● Container auto-scaling ● Provides basic load balancing OOTB ● Canary deployments ● Health checks ● Documentation
  • 18.
    Kubernetes Distributions ● GoogleKubernetes Engine ● Amazon ECS ● CoreOS Tectonic ● OpenShift by Red Hat ● StackPoint ● … much more!
  • 19.
  • 20.
    Development with Containers ●Pack binaries and artifacts in the container image ● Expose required functionality/ports of container ● Take the same image and run a container anywhere* ● Overruled “works on my laptop” argument to a great extent ● One container supposed to do only one thing (UNIX philosophy) * physical/virtual machine, any distro, any cloud
  • 21.
    Developer workflow ● Everydev is working on their fork of the code ● Before merging into main repo, it goes through automated tests ● Tests happen on environment similar to production ● Container images are created, tagged and pushed ● Quick feedback loop on the tests ● Also called Continuous Integration (CI of CI/CD) ● Great piece written by Martin Fowler
  • 22.
    Deployment with Containers ●Automation FTW but one of the most critical part ● Ops teams deploy code multiple time a day ● Inter-container communication has to be smooth ● Blue-Green deployments becoming popular ● Rollback in case something blows up ● All these is easier said than done
  • 23.
  • 24.
    Monoliths ● Single WARfile that runs everything ● Seems perfect initially till the time it becomes huge ● CI/CD can take long time as size increases ● Scaling can become an issue ● In short all issues you can imagine related with larger size
  • 25.
    Microservices ● Break servicedown into pieces: database, API, front-end, etc. ● Specialized frameworks can be used for tasks ● Individual services can be scaled up/down ● APIs can be reused by other services
  • 26.
  • 27.
    Tools ● Git forversion controlling the code ● Jenkins, Travis for CI ● Docker, Buildah to create containers ● OpenShift for deployment and built-in CI/CD mechanism ● Elastic, Logstash, Kibana for logging aggregation ● Prometheus, Zabbix for monitoring ● … much more!
  • 28.
    Learn more! Join theseand more communities to learn and/or share! ● Kubernetes Ahmedabad ● Docker Ahmedabad ● Ansible Ahmedabad ● DigitalOcean Ahmedabad
  • 29.
    About Me ● Engineer@ Red Hat ● Love building tech communities, sharing knowledge and organizing + speaking at meetups ● Twitter: @dharm1t Web: dharmitshah.com
  • 30.
    Resources ● Google Borg ●Continuous Integration - Martin Fowler (ThoughtWorks) ● Continuous Deployment - Viktor Farcic (Cloudbees) ● Kubernetes Documentation ● Docker ● Buildah ● OpenShift by Red Hat ● All Kubernetes distributions ● Containers are Linux