KEMBAR78
Containers and Docker | PDF
CONTAINERS AND DOCKER
Amin Afshar
System Administrator
Avid Arvand
Shahid Beheshti University
Natural Language Processing (NLP) Lab
May 2019
AGENDA
  Virtualization / Hypervisors / Virtual Machines
  Containers
  Containers vs. Virtual Machines
  Linux kernel features
  Docker Platform
  Demo
VIRTUALIZATION
HYPERVISORS
BARE METAL, NATIVE OR TYPE I
HYPERVISORS
EMBEDDED, HOSTED OR TYPE II
CONTAINERS
CONTAINERS
  Containers are processes
  Containers are isolated processes
  Share the same OS kernel
  OS-level virtualization
  Another abstraction layer on top of the hypervisor
CONTAINERS
VIRTUALIZATION VS. CONTAINERIZATION
CONTAINERS VS. VIRTUAL MACHINES
CONTAINERS AND VIRTUAL MACHINES
LINUX KERNEL FEATURES:
NAMESPACES
 Control what a process can see.
 Namespaces “trick” a process into seeing an
entirely separate machine.
  originated in 2002 in the 2.4.19 kernel
pid namespaces
mtn namespace
LINUX KERNEL FEATURES:
CGROUPS
  Control what a process can use.
  Control Groups (cgroups) isolate the resource (cpu, memory, …) usage.
  Started at Google in 2006
  Merged into linux kernel mainline v2.6.24 released in Jan. 2008.
  Redesign in 2013 in kernel v3.15
LINUX KERNEL FEATURES:
CGROUPS
CONTAINERS HISTORY
Docker
MOST POPULAR AND WIDELY USED
CONTAINER PLATFORM
  Solomon Hykes started Docker as an internal project within dotCloud PaaS
  PyCon 2013: The Future of Containers
  Open sourced in March 2013
  Introduced an ecosystem for managing containers
  Incredible adoption rate in just few years
  A highly efficient, layered container image model
  A global and local container registries
  A clean REST API, and a CLI
Docker Platform
Image
The basis of a Docker container.
Container
The image when it is ‘running.’
Docker Engine
Manages Images and Containers.
Registry
Stores, distributes and manages Docker images
Docker Engine components
Client-Server Architecture
Docker Image
• a read-only template
• Built up from a series of layers
• Each layer represents an instruction in the image’s Dockerfile
• Each layer except the very last one is read-only
Dockerfile
FROM nginx
ENV AUTHOR=Docker
WORKDIR /usr/share/nginx/html
COPY Hello_docker.html /usr/share/nginx/html
CMD cd /usr/share/nginx/html && sed -e s/Docker/"$AUTHOR"/ Hello_docker.html > index.html ; nginx -g
'daemon off;'
Docker Image
Docker Image
Union File System
WHY DOCKER
  The IT landscape is changing
Microservices
DevOpsCloud
Migrate workloads to cloud
Portability across environments
WHY DOCKER
  Applications are transforming
Loosely
Coupled
Services
Many Small
Servers or devices
~2000 Today
Monolithic
Big Servers
Slow
changing
Rapidly
updated
WHY DOCKER
WHY DOCKER
  Tug of War Between Developers and Ops (Diverse Organizations)
Developers IT Operations
WHY DOCKER
  Multiple Stacks, Multiple Stages (CI/CD) = Complexity
1. Development 2. Test 3. Stage / Production
WHY DOCKER
  SOLVING THE DEPLOYMENT MATRIX
Build, Ship, Run
BUILD (Development)
Development Environments
SHIP (Distribution)
Secure Content & Collaboration
RUN (Deployment)
Deploy, Manage, Scale
Registry
Multi-container
apps
Engines running on
servers in cloud or
datacenter
Images stored in
repos
Clients pull and
push images
BENEFITS OF DOCKER
  Standardized packaging format for software and dependencies (primary and
biggest benefit)
  Portability, ability to move between infrastructure
  Dev/Prod Parity
  Increase Agility
  Speed, No OS to boot, applications online in seconds
  Efficiency, Less OS overhead, ImprovedVM density
  Natural fit for microservices style apps (self-contained services)
  Secure, reduced attack surface
• A tool for defining and running multi-container Docker applications
• Use a Compose file to configure application’s services
• With a single command, create and start all the services from configuration (docker-
compose up)
• Single host deployments
• Great for development, testing, and staging environments, as well as CI workflows
• Speed up project onboarding
Docker Compose
docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
- logvolume01:/var/log
links:
- redis
redis:
image: redis
volumes:
logvolume01: {}
Docker and nvidia
• Configure gpu access for container leveraging nvidia hardware
• Linux kernel > 3.10 nvidia architecture > fermi 2.1 2011
• Install cuda-drivers
• Install nvidia-docker2 and restart docker daemon
• Use nvidia/cuda images
Docker and nvidia
Demo
Twitter: @aminafshar
Telegram: @aminafshar
Thank You.

Containers and Docker