SlideShare a Scribd company logo
6
Most read
7
Most read
8
Most read
INTRODUCTION TO
CONTAINERIZATION
BALINT PATO
SOFTWARE CRAFTSMANSHIP NYC MEETUP
11/17/2016
CURRICULUM FOR TODAY
▸ slides: curriculum
▸ hands-on: install docker, hello-world
▸ slides: containerization foundations
▸ hands-on: build an image from an app, run it, peak into the container
▸ slides: isolation and resource management
▸ hands-on: talking to the daemon, pushing the image to DockerHub,
isolation experiments!
▸ discussion
INTRODUCTION TO CONTAINERIZATION
INTRODUCTION TO CONTAINERIZATION
LET’S START HANDS-ON
TEST
> docker run hello-world
INTRODUCTION TO CONTAINERIZATION
WHAT IS CONTAINERIZATION?
▸ metaphor I.

shipping container
▸ standard packaging
▸ isolation method
▸ composability
INTRODUCTION TO CONTAINERIZATION
WHAT IS CONTAINERIZATION?
▸ metaphor II.

lightweight, fast virtualization
▸ a container is like a virtual machine
but magnitudes faster to spin it up
▸ own networking stack
▸ own filesystem
▸ own process IDs
▸ …but it runs on a host machine!
INTRODUCTION TO CONTAINERIZATION
BENEFITS: WHAT ARE CONTAINERS GOOD FOR?
▸ repeatability: I build the image once, and
deploy (roughly) the same thing prod
▸ portability: as long as the runtime is
available for a platform, the container can
run there too.
▸ reusable filesystem setup: layers are the
base of reuse
▸ standard execution and distribution: most
(I consider windows preview only) software
stacks are supported
▸ density: I can deploy multiple instances next
to each other and split up the resources
INTRODUCTION TO CONTAINERIZATION
BENEFITS: 

CLOUD NATIVE ARCHITECTURE
an important piece 

in the cloud puzzle
INTRODUCTION TO CONTAINERIZATION
DEFINITIONS
▸ containerization platform: a family of technologies to isolate processes from each other,
so that processes run as if they are running in a normal operating system while - enforced
by the container runtime - they actually share the resources of a single host without having
the ability to see each other's or the host's processes and resources. A platform also has
opinion about the runtime and the lifecycle of the image, from building to distribution. 

Examples: LXC, Rkt, Docker
▸ container runtime: container execution environment, which enforces the limited shares
of resources (e.g. cpu, memory, disk) allocated to the containerized application, also
exposes API and tools around managing containers. 

Examples: LXD, Docker daemon, Rkt process
▸ image: an image defines the filesystem and execution parameters for the container.
Images can be layered, composable, depending on the format. 

Examples: Docker image, appc, LXC image format
EXERCISE: LET’S BUILD AN IMAGE!
INTRODUCTION TO CONTAINERIZATION
FROM alpine
RUN apk add --no-cache bash curl py-pip
RUN pip install --upgrade pip
RUN pip install flask
COPY ./app.py /
ENTRYPOINT python /app.py
2. create docker-start/Dockerfile with the following content
> git clone https://github.com/balopat/docker-starter
1. get some sample code, discuss the flask app
> docker build -t nanoservice .
3. build the image and discuss: What can these instructions mean?
EXERCISE: LET’S RUN IT!
INTRODUCTION TO CONTAINERIZATION
> docker images
1. list images on your machine, discuss: what can you see?
> docker run -d -p 1234:5000 nanoservice
2. spin up a container, discuss: what’s the output?
> docker ps
3. list running containers, discuss the output
> docker logs <container-id>
4. get the logs, discuss the output - try accessing the app
EXERCISE: WHAT’S IN THE BOX?
INTRODUCTION TO CONTAINERIZATION
> docker exec <container-id> ls /
1. run this and discuss
> docker exec -ti <container-id> bash
2. run this and experiment around
container> ps ax
3. how many processes are in the container? what are their PIDs?
container> curl localhost:5000
4. try accessing the app from inside
INTRODUCTION TO CONTAINERIZATION
KEEP IN MIND:
THE DOCKER ARCHITECTURE: CLIENT-SERVER
INTRODUCTION TO CONTAINERIZATION
ISOLATION AND RESOURCE SHARING
▸ linux namespaces 

http://man7.org/linux/man-pages/man7/namespaces.7.html
▸ hostname
▸ net
▸ pid
▸ users
▸ mounts
▸ …
▸ linux cgroups 

https://en.wikipedia.org/wiki/Cgroups
▸ CPU share
▸ CPU set
▸ memory
▸ block I/O
▸ network priority
▸ …
INTRODUCTION TO CONTAINERIZATION
EXERCISE: PUNCH A WHOLE ON THE CONTAINER
> docker run -d -p 1234:5000 nanoservice
1. spin up a container with port mapping and discuss: what’s the output? 

what does docker ps show?
2. On Mac + Ubuntu desktops just access http://localhost:5000,
[on Windows with Docker Toolbox:
a.) find the boot2docker VM’s IP: run ‘docker-machine ls’ this will give you
a tcp://<boot2dockerVMIP>:XXXX in the response
b.) you can access the app at http://<boot2dockerVMIP>:1234
INTRODUCTION TO CONTAINERIZATION
https://hub.docker.com
1. Register on docker hub
> docker login
2. login
> docker tag nanoservice <username>/nanoservice
3. re-tag our service to setup the repository (check with docker images)
> docker push <username>/nanoservice
4. push!
EXERCISE: PUSH IT TO DOCKERHUB
EXERCISE: TALKING TO THE DAEMON
INTRODUCTION TO CONTAINERIZATION
> docker run -it --privileged -v /var/run/docker.sock:/var/
run/docker.sock appropriate/curl sh
> curl google.com
1. we’ll need curl
> ls /var/run/docker.sock
2. find /var/run/docker.sock
> curl --unix-socket /var/run/docker.sock http://localhost/images/json
3. let’s query the daemon!
EXERCISE: LIMIT MEMORY
INTRODUCTION TO CONTAINERIZATION
> docker run -ti -m 300M debian bash
1.Let’s get a shell limited to 300M of memory
> docker stats
2. another window, let’s see the amount of RAM you have!
https://docs.docker.com/engine/reference/run/
Loads of options to manage resource usage of apps:
> cat <(yes | tr n x | head -c $((1024*1024*300))) <(sleep 10) | grep n
3. let’s load stuff in the memory, follow the action in the docker stats!
EXERCISE: MAX OUT YOUR CPU - ONLY DO THIS IF YOU HAVE MORE THAN 1 CORE!
INTRODUCTION TO CONTAINERIZATION
> docker run -ti --cpuset-cpus="1" --cpu-quota=10000 debian bash
1.Let’s get a shell limited to 1 cpu and only 10% of it
> :(){ :|:& };:
2. Let’s drop the fork bomb
> docker stats
3. on another tab - let’s see the stats
> docker kill <container-id>
4. kill the cpu killer
CURRICULUM FOR TODAY
▸ slides: curriculum
▸ hands-on: install docker, hello-world
▸ slides: containerization foundations
▸ hands-on: build an image from an app, run it, peak into the container
▸ slides: isolation and resource management
▸ hands-on: talking to the daemon, pushing the image to DockerHub,
isolation experiments!
▸ well done! we can get to the discussion :)
INTRODUCTION TO CONTAINERIZATION

More Related Content

PPTX
Containerization
PPTX
Docker introduction (1)
PPTX
Dockers and containers basics
PPT
Docker introduction
PDF
Docker Introduction
PDF
Docker Introduction
PPTX
Docker intro
PPTX
Introduction to Docker - 2017
Containerization
Docker introduction (1)
Dockers and containers basics
Docker introduction
Docker Introduction
Docker Introduction
Docker intro
Introduction to Docker - 2017

What's hot (20)

PPTX
Docker introduction
PDF
Kubernetes
PPTX
Docker 101 : Introduction to Docker and Containers
PDF
Containers: The What, Why, and How
PDF
What Is Kubernetes | Kubernetes Introduction | Kubernetes Tutorial For Beginn...
PPTX
Getting started with Docker
PPTX
Docker introduction &amp; benefits
PDF
Introduction to Docker - VIT Campus
ODP
Introduction to Ansible
PPTX
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
PPTX
What is Docker
PDF
Docker 101: Introduction to Docker
PDF
Introduction to Docker storage, volume and image
PDF
Introduction to Docker
PDF
Introduction to docker
PDF
Kubernetes 101
PPTX
Docker: From Zero to Hero
PPTX
Docker basics
PDF
Kubernetes architecture
Docker introduction
Kubernetes
Docker 101 : Introduction to Docker and Containers
Containers: The What, Why, and How
What Is Kubernetes | Kubernetes Introduction | Kubernetes Tutorial For Beginn...
Getting started with Docker
Docker introduction &amp; benefits
Introduction to Docker - VIT Campus
Introduction to Ansible
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
What is Docker
Docker 101: Introduction to Docker
Introduction to Docker storage, volume and image
Introduction to Docker
Introduction to docker
Kubernetes 101
Docker: From Zero to Hero
Docker basics
Kubernetes architecture
Ad

Viewers also liked (20)

PDF
Containerization is more than the new Virtualization: enabling separation of ...
PPTX
Containerization
PPTX
Software Containerization
PPTX
Containerization (Export/Import Goods)
PDF
A Primer to Containerization & Microservices
PPTX
Hide your development environment and application in a container
PDF
Containerization using docker
PPT
Essence Of Containerizati on 230508
PDF
Virtualization with Vagrant (ua.pycon 2011)
PDF
Docker containerization cookbook
PDF
Vagrant and docker
PPTX
Virtual Container - Docker
PPTX
Vagrant + Docker
PDF
Vagrant for Virtualized Development
PPTX
Vagrant vs Docker
PDF
Let’s start Continuous Integration with jenkins
PDF
Enterprise Development Trends 2016 - Cloud, Container and Microservices Insig...
PDF
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
PDF
Introduction to Vagrant
Containerization is more than the new Virtualization: enabling separation of ...
Containerization
Software Containerization
Containerization (Export/Import Goods)
A Primer to Containerization & Microservices
Hide your development environment and application in a container
Containerization using docker
Essence Of Containerizati on 230508
Virtualization with Vagrant (ua.pycon 2011)
Docker containerization cookbook
Vagrant and docker
Virtual Container - Docker
Vagrant + Docker
Vagrant for Virtualized Development
Vagrant vs Docker
Let’s start Continuous Integration with jenkins
Enterprise Development Trends 2016 - Cloud, Container and Microservices Insig...
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Introduction to Vagrant
Ad

Similar to Intro to containerization (20)

PDF
時代在變 Docker 要會:台北 Docker 一日入門篇
PPTX
Dockerizing a Symfony2 application
PDF
手把手帶你學Docker 03042017
PPTX
ABCs of docker
PDF
手把手帶你學 Docker 入門篇
PDF
Docker workshop 0507 Taichung
PDF
Containers, Docker, and Microservices: the Terrific Trio
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
PDF
codemotion-docker-2014
PPTX
Novices guide to docker
PPTX
Docker training
PPTX
Introduction to docker
PDF
Orchestrating Docker with OpenStack
PDF
Docker研習營
PDF
Docker Essentials Workshop— Innovation Labs July 2020
PDF
Docker
PDF
Docker and the Container Revolution
PDF
Docker+java
PDF
Docker: A New Way to Turbocharging Your Apps Development
PDF
Automate drupal deployments with linux containers, docker and vagrant
時代在變 Docker 要會:台北 Docker 一日入門篇
Dockerizing a Symfony2 application
手把手帶你學Docker 03042017
ABCs of docker
手把手帶你學 Docker 入門篇
Docker workshop 0507 Taichung
Containers, Docker, and Microservices: the Terrific Trio
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
codemotion-docker-2014
Novices guide to docker
Docker training
Introduction to docker
Orchestrating Docker with OpenStack
Docker研習營
Docker Essentials Workshop— Innovation Labs July 2020
Docker
Docker and the Container Revolution
Docker+java
Docker: A New Way to Turbocharging Your Apps Development
Automate drupal deployments with linux containers, docker and vagrant

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
KodekX | Application Modernization Development
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25 Week I
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KodekX | Application Modernization Development
Unlocking AI with Model Context Protocol (MCP)
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Intro to containerization

  • 1. INTRODUCTION TO CONTAINERIZATION BALINT PATO SOFTWARE CRAFTSMANSHIP NYC MEETUP 11/17/2016
  • 2. CURRICULUM FOR TODAY ▸ slides: curriculum ▸ hands-on: install docker, hello-world ▸ slides: containerization foundations ▸ hands-on: build an image from an app, run it, peak into the container ▸ slides: isolation and resource management ▸ hands-on: talking to the daemon, pushing the image to DockerHub, isolation experiments! ▸ discussion INTRODUCTION TO CONTAINERIZATION
  • 3. INTRODUCTION TO CONTAINERIZATION LET’S START HANDS-ON TEST > docker run hello-world
  • 4. INTRODUCTION TO CONTAINERIZATION WHAT IS CONTAINERIZATION? ▸ metaphor I.
 shipping container ▸ standard packaging ▸ isolation method ▸ composability
  • 5. INTRODUCTION TO CONTAINERIZATION WHAT IS CONTAINERIZATION? ▸ metaphor II.
 lightweight, fast virtualization ▸ a container is like a virtual machine but magnitudes faster to spin it up ▸ own networking stack ▸ own filesystem ▸ own process IDs ▸ …but it runs on a host machine!
  • 6. INTRODUCTION TO CONTAINERIZATION BENEFITS: WHAT ARE CONTAINERS GOOD FOR? ▸ repeatability: I build the image once, and deploy (roughly) the same thing prod ▸ portability: as long as the runtime is available for a platform, the container can run there too. ▸ reusable filesystem setup: layers are the base of reuse ▸ standard execution and distribution: most (I consider windows preview only) software stacks are supported ▸ density: I can deploy multiple instances next to each other and split up the resources
  • 7. INTRODUCTION TO CONTAINERIZATION BENEFITS: 
 CLOUD NATIVE ARCHITECTURE an important piece 
 in the cloud puzzle
  • 8. INTRODUCTION TO CONTAINERIZATION DEFINITIONS ▸ containerization platform: a family of technologies to isolate processes from each other, so that processes run as if they are running in a normal operating system while - enforced by the container runtime - they actually share the resources of a single host without having the ability to see each other's or the host's processes and resources. A platform also has opinion about the runtime and the lifecycle of the image, from building to distribution. 
 Examples: LXC, Rkt, Docker ▸ container runtime: container execution environment, which enforces the limited shares of resources (e.g. cpu, memory, disk) allocated to the containerized application, also exposes API and tools around managing containers. 
 Examples: LXD, Docker daemon, Rkt process ▸ image: an image defines the filesystem and execution parameters for the container. Images can be layered, composable, depending on the format. 
 Examples: Docker image, appc, LXC image format
  • 9. EXERCISE: LET’S BUILD AN IMAGE! INTRODUCTION TO CONTAINERIZATION FROM alpine RUN apk add --no-cache bash curl py-pip RUN pip install --upgrade pip RUN pip install flask COPY ./app.py / ENTRYPOINT python /app.py 2. create docker-start/Dockerfile with the following content > git clone https://github.com/balopat/docker-starter 1. get some sample code, discuss the flask app > docker build -t nanoservice . 3. build the image and discuss: What can these instructions mean?
  • 10. EXERCISE: LET’S RUN IT! INTRODUCTION TO CONTAINERIZATION > docker images 1. list images on your machine, discuss: what can you see? > docker run -d -p 1234:5000 nanoservice 2. spin up a container, discuss: what’s the output? > docker ps 3. list running containers, discuss the output > docker logs <container-id> 4. get the logs, discuss the output - try accessing the app
  • 11. EXERCISE: WHAT’S IN THE BOX? INTRODUCTION TO CONTAINERIZATION > docker exec <container-id> ls / 1. run this and discuss > docker exec -ti <container-id> bash 2. run this and experiment around container> ps ax 3. how many processes are in the container? what are their PIDs? container> curl localhost:5000 4. try accessing the app from inside
  • 12. INTRODUCTION TO CONTAINERIZATION KEEP IN MIND: THE DOCKER ARCHITECTURE: CLIENT-SERVER
  • 13. INTRODUCTION TO CONTAINERIZATION ISOLATION AND RESOURCE SHARING ▸ linux namespaces 
 http://man7.org/linux/man-pages/man7/namespaces.7.html ▸ hostname ▸ net ▸ pid ▸ users ▸ mounts ▸ … ▸ linux cgroups 
 https://en.wikipedia.org/wiki/Cgroups ▸ CPU share ▸ CPU set ▸ memory ▸ block I/O ▸ network priority ▸ …
  • 14. INTRODUCTION TO CONTAINERIZATION EXERCISE: PUNCH A WHOLE ON THE CONTAINER > docker run -d -p 1234:5000 nanoservice 1. spin up a container with port mapping and discuss: what’s the output? 
 what does docker ps show? 2. On Mac + Ubuntu desktops just access http://localhost:5000, [on Windows with Docker Toolbox: a.) find the boot2docker VM’s IP: run ‘docker-machine ls’ this will give you a tcp://<boot2dockerVMIP>:XXXX in the response b.) you can access the app at http://<boot2dockerVMIP>:1234
  • 15. INTRODUCTION TO CONTAINERIZATION https://hub.docker.com 1. Register on docker hub > docker login 2. login > docker tag nanoservice <username>/nanoservice 3. re-tag our service to setup the repository (check with docker images) > docker push <username>/nanoservice 4. push! EXERCISE: PUSH IT TO DOCKERHUB
  • 16. EXERCISE: TALKING TO THE DAEMON INTRODUCTION TO CONTAINERIZATION > docker run -it --privileged -v /var/run/docker.sock:/var/ run/docker.sock appropriate/curl sh > curl google.com 1. we’ll need curl > ls /var/run/docker.sock 2. find /var/run/docker.sock > curl --unix-socket /var/run/docker.sock http://localhost/images/json 3. let’s query the daemon!
  • 17. EXERCISE: LIMIT MEMORY INTRODUCTION TO CONTAINERIZATION > docker run -ti -m 300M debian bash 1.Let’s get a shell limited to 300M of memory > docker stats 2. another window, let’s see the amount of RAM you have! https://docs.docker.com/engine/reference/run/ Loads of options to manage resource usage of apps: > cat <(yes | tr n x | head -c $((1024*1024*300))) <(sleep 10) | grep n 3. let’s load stuff in the memory, follow the action in the docker stats!
  • 18. EXERCISE: MAX OUT YOUR CPU - ONLY DO THIS IF YOU HAVE MORE THAN 1 CORE! INTRODUCTION TO CONTAINERIZATION > docker run -ti --cpuset-cpus="1" --cpu-quota=10000 debian bash 1.Let’s get a shell limited to 1 cpu and only 10% of it > :(){ :|:& };: 2. Let’s drop the fork bomb > docker stats 3. on another tab - let’s see the stats > docker kill <container-id> 4. kill the cpu killer
  • 19. CURRICULUM FOR TODAY ▸ slides: curriculum ▸ hands-on: install docker, hello-world ▸ slides: containerization foundations ▸ hands-on: build an image from an app, run it, peak into the container ▸ slides: isolation and resource management ▸ hands-on: talking to the daemon, pushing the image to DockerHub, isolation experiments! ▸ well done! we can get to the discussion :) INTRODUCTION TO CONTAINERIZATION