SlideShare a Scribd company logo
Michael Irwin - @mikesir87
Virginia Tech; Docker Captain
Containers
for Beginners
@mikesir87
Disclaimer: I cannot explain
sprankle pods either!
@mikesir87
Quick History of Shipping
Source: https://www.publicdomainpictures.net/en/view-image.php?image=275355 Source: https://en.wikipedia.org/wiki/Rail_freight_in_Great_Britain Source: https://pxhere.com/en/photo/553345
Software = Shipping?
@mikesir87
Shipping in Software
Source: https://www.usafe.af.mil/News/Photos/igphoto/2000887438/
@mikesir87
Either of these two scenarios
sound familiar to you?
@mikesir87
Welcome!
Glad to have
you on the
team!
Clone the repo,use the wiki forsetup instructions,and update the
docs as needed.Good luck!
@mikesir87
@mikesir87
Imagine if...
@mikesir87
Creating Images
• Best practice is to use a Dockerfile
• A text file that serves as a script to build an image
• Build using the docker build command
FROM node
WORKDIR /app
COPY package.json yarn.lock .
RUN yarn install
COPY src ./src
CMD ["node", "src/index.js"]
@mikesir87
Sharing Images
• Once built, the image is only available locally
• To share, push it to a registry using docker push
• Docker Hub is the default registry
• Docker EE includes the Docker Trusted Registry
• Many other third-party offerings available too
• Once shared, others can pull the image
Source: https://landscape.cncf.io
@mikesir87
Let’s build an image!
@mikesir87
What’s a container then?
• While a container looks like a VM, it isn’t!
• A container is just another process on the machine
• It uses namespaces and control groups (cgroups) to provide
isolation
• Namespaces include network, process, user, IPC, mount, and others
• To run a container, use the docker container run command
@mikesir87
@mikesir87
Containers vs VMs
Infrastructure
Host Operating System
Hypervisor
Guest OS
Bins/Libs
App 1
Guest OS
Bins/Libs
App 2
Guest OS
Bins/Libs
App 3
Infrastructure
Operating System
Bins/Libs
App 1
Bins/Libs
App 2
Bins/Libs
App 3
Docker
Daemon
@mikesir87
Image Layering
• Images are composed of layers of filesystem changes
• Each layer can add or remove from the previous layer
• Each layer’s filesystem changes are stored as a single tar file
• Each command in a Dockerfile creates a new layer
• Use the docker image history command to see the layers and the
command that was used to create each layer
@mikesir87
Layer contents
file1 file2 file3 file4
file2 file5
file1 file2 file3 file4 file5
Layer 1
Layer 2
Merged
• Layers are unioned together to make a full filesystem
• Each layer can add files as needed
• Files in “higher” layers replace the same file in “lower” layers
• The container uses the “merged” view
@mikesir87
What about deleted files?
● Deleted files are represented in a layer as a “whiteout” file
● Whiteout files are only used by the filesystem driver and not visible
in the merged filesystem
file1 file2 file3 file4
file2 file5
file1 file2 file3 file5
Layer 1
Layer 2
Merged
.wh.file4 Layer 3
@mikesir87
WARNING!
Be careful what you put into images.
Deleted files might not actually be
gone!
@mikesir87
Two Best Practices Incoming!
@mikesir87
Clean up as you go!
● Don’t wait until the end of the Dockerfile to “clean” up
● Chain RUN commands together to clean things as you go
FROM ubuntu
RUN apt-get update
RUN apt-get install -y python python-pip
RUN pip install awscli
RUN apt-get autoremove --purge -y python-pip
FROM ubuntu
RUN apt-get update && 
apt-get install -y python python-pip && 
pip install awscli && 
apt-get autoremove --purge -y python-pip && 
rm -rf /var/lib/apt/lists/*
Net change of image size from
512MB to 183MB (64% reduction)
@mikesir87
Keep images tight and focused
• Only install the deps/tools/packages that are necessary
• Use multi-stage builds to separate build-time and run-time
dependencies
FROM node AS build
WORKDIR /usr/src/app
COPY package.json yarn.lock .
RUN yarn install
COPY public ./public
COPY src ./src
RUN yarn build
FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/src/app/build /usr/share/nginx/html
Sample multi-stage build for a React app
@mikesir87
How do you persist data?
@mikesir87
● Volumes provide the ability to persist/supply data
● Bind mount volumes
○ You choose where to persist the data
○ Example: -v $HOME/mysql-data:/var/lib/mysql
● Named volumes
○ Let Docker choose where to persist the data
○ Can use docker volume inspect to find actual location
○ Example: -v mysql-data:/var/lib/mysql
Volumes
@mikesir87
Show me these volumes!
@mikesir87
@mikesir87
Docker Compose
• Makes defining and running multi-container apps super easy
• Uses a YAML file for configuration (docker-compose.yml)
• Often included in project source repo at the root of the project
• With a single command, start all containers/services for an app
• Tool is bundled with Docker Desktop
@mikesir87
Docker Networking
• Think of networking in terms of communication boundaries/isolation
• If two containers are on the same network, they can talk to each other
• Docker runs its own DNS resolver on each network
• Allows it to resolve IP addresses of other containers using “aliases”
API1
Database
Reverse Proxy
React App
API2
Cache
@mikesir87
Quick compose demo!
@mikesir87
Container Orchestration
• Orchestration provides the ability to manage the running of
container workloads, often over a fleet of machines
• You define the expected state (the desired state)
• The system then tries to make actual state reflect expected state
@mikesir87
Actors in Orchestration
• Every orchestrator has the concept of two types
of nodes
• Managers
• Serve as the brains of the cluster
• Maintain state and schedule work
• Sometimes called masters
• Worker nodes
• Perform the actual work, as instructed by a manager
• Sometimes called agents or nodes
@mikesir87
Various Orchestrators
• Docker Swarm
• Shipped with the Docker engine
• Very user friendly and easy to get up and running
• Satisfies most needs, though not all; built to be extensible, but takes some work
• Kubernetes
• Spun out of work done within Google and contributed to CNCF
• Think of it more as a toolkit - so not as easy to get up and running
• Very configurable and extensible
• Amazon ECS
• Made by Amazon Web Services and provided for free
• Provides deep integration with AWS resources (IAM, ALBs, Auto-scaling, etc.)
@mikesir87
Quick Swarm Demo!
@mikesir87
• Containers/images are here to standardize application packaging
• No longer require host configuration
• Docker Compose builds on the abstraction to make multi-service apps easier
• Container orchestration builds on this idea
• Be mindful of how you build your images and what you include
• Volumes allow data to be persisted longer than the container
• Networking serves provides communication paths/isolation
Recap
@mikesir87
WARNING!
Containers are NOT a silver bullet
that will fix your company culture
Thank you!
Rate the session!
Keep in touch!
@mikesir87; mikesir87@vt.edu

More Related Content

PDF
Rancher Rodeo
PPTX
Infrastructure as code (iac) - Terraform for AWS
PDF
Veeam Availability top 10 reasons to choose veeam - long
PPTX
C++ GUI 라이브러리 소개: Qt & Nana
PPTX
Terraform Basics
PPTX
Docker introduction
PDF
Terraform: An Overview & Introduction
PDF
Terraform -- Infrastructure as Code
Rancher Rodeo
Infrastructure as code (iac) - Terraform for AWS
Veeam Availability top 10 reasons to choose veeam - long
C++ GUI 라이브러리 소개: Qt & Nana
Terraform Basics
Docker introduction
Terraform: An Overview & Introduction
Terraform -- Infrastructure as Code

What's hot (20)

PDF
Introduction to Kubernetes and GKE
PPTX
Python/Flask Presentation
PPTX
Docker: From Zero to Hero
PDF
Cgroupあれこれ-第4回コンテナ型仮想化の情報交換会資料
PPTX
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB Architecture
PDF
Docker internals
PDF
Qt Internationalization
 
ODP
Java EE Pattern: Entity Control Boundary Pattern and Java EE
PPTX
プログラミング言語の比較表
PPTX
Final terraform
PPTX
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
PDF
AWS CDK Introduction
PDF
Kubernetes
PPTX
プロが解説!Hinemosによる運用管理テクニック
PDF
Terraform modules and (some of) best practices
PDF
Open shift 4-update
PDF
Helm - Application deployment management for Kubernetes
PDF
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
DOCX
IMP questions for System programming for GTU
PPTX
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
Introduction to Kubernetes and GKE
Python/Flask Presentation
Docker: From Zero to Hero
Cgroupあれこれ-第4回コンテナ型仮想化の情報交換会資料
Toronto Virtual Meetup #7 - Anypoint VPC, VPN and DLB Architecture
Docker internals
Qt Internationalization
 
Java EE Pattern: Entity Control Boundary Pattern and Java EE
プログラミング言語の比較表
Final terraform
Terraform in production - experiences, best practices and deep dive- Piotr Ki...
AWS CDK Introduction
Kubernetes
プロが解説!Hinemosによる運用管理テクニック
Terraform modules and (some of) best practices
Open shift 4-update
Helm - Application deployment management for Kubernetes
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
IMP questions for System programming for GTU
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
Ad

Similar to DCSF19 Containers for Beginners (20)

PDF
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
PPTX
Getting Started with Docker
PPTX
Getting started with Docker
PDF
Containers in depth – Understanding how containers work to better work with c...
PDF
Securing Containers From Day One | null Ahmedabad Meetup
PDF
Securing Containers From Day One | null Ahmedabad Meetup
PPTX
Virtualization, Containers, Docker and scalable container management services
PDF
DEVOPS UNIT 4 docker and services commands
PDF
Introduction to Docker and Monitoring with InfluxData
PDF
JOSA TechTalks - Docker in Production
PPTX
Docker Fundamasadsasdasdassadentals 101 - Dark.pptx
PDF
Dockerfile
PPTX
Containerization using docker and its applications
PPTX
Containerization using docker and its applications
PPTX
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
PPTX
Docker and SDL Web/Tridion - SDL UK User Group April 2017
PPTX
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
PPTX
Docker and Microservice
PPTX
Docker and kubernetes
PDF
Docker and Puppet for Continuous Integration
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
Getting Started with Docker
Getting started with Docker
Containers in depth – Understanding how containers work to better work with c...
Securing Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad Meetup
Virtualization, Containers, Docker and scalable container management services
DEVOPS UNIT 4 docker and services commands
Introduction to Docker and Monitoring with InfluxData
JOSA TechTalks - Docker in Production
Docker Fundamasadsasdasdassadentals 101 - Dark.pptx
Dockerfile
Containerization using docker and its applications
Containerization using docker and its applications
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
Docker and SDL Web/Tridion - SDL UK User Group April 2017
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Docker and Microservice
Docker and kubernetes
Docker and Puppet for Continuous Integration
Ad

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
PDF
How to Improve Your Image Builds Using Advance Docker Build
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
Securing Your Containerized Applications with NGINX
PDF
How To Build and Run Node Apps with Docker and Compose
PDF
Hands-on Helm
PDF
Distributed Deep Learning with Docker at Salesforce
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
PDF
Monitoring in a Microservices World
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
PDF
Predicting Space Weather with Docker
PDF
Become a Docker Power User With Microsoft Visual Studio Code
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
PDF
Kubernetes at Datadog Scale
PDF
Labels, Labels, Labels
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
PDF
Developing with Docker for the Arm Architecture
Containerize Your Game Server for the Best Multiplayer Experience
How to Improve Your Image Builds Using Advance Docker Build
Build & Deploy Multi-Container Applications to AWS
Securing Your Containerized Applications with NGINX
How To Build and Run Node Apps with Docker and Compose
Hands-on Helm
Distributed Deep Learning with Docker at Salesforce
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Monitoring in a Microservices World
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Predicting Space Weather with Docker
Become a Docker Power User With Microsoft Visual Studio Code
How to Use Mirroring and Caching to Optimize your Container Registry
Monolithic to Microservices + Docker = SDLC on Steroids!
Kubernetes at Datadog Scale
Labels, Labels, Labels
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Build & Deploy Multi-Container Applications to AWS
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Developing with Docker for the Arm Architecture

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
KodekX | Application Modernization Development
PDF
Empathic Computing: Creating Shared Understanding
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The AUB Centre for AI in Media Proposal.docx
Machine learning based COVID-19 study performance prediction
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
MYSQL Presentation for SQL database connectivity
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...

DCSF19 Containers for Beginners

  • 1. Michael Irwin - @mikesir87 Virginia Tech; Docker Captain Containers for Beginners
  • 2. @mikesir87 Disclaimer: I cannot explain sprankle pods either!
  • 3. @mikesir87 Quick History of Shipping Source: https://www.publicdomainpictures.net/en/view-image.php?image=275355 Source: https://en.wikipedia.org/wiki/Rail_freight_in_Great_Britain Source: https://pxhere.com/en/photo/553345
  • 5. @mikesir87 Shipping in Software Source: https://www.usafe.af.mil/News/Photos/igphoto/2000887438/
  • 6. @mikesir87 Either of these two scenarios sound familiar to you?
  • 7. @mikesir87 Welcome! Glad to have you on the team! Clone the repo,use the wiki forsetup instructions,and update the docs as needed.Good luck!
  • 10. @mikesir87 Creating Images • Best practice is to use a Dockerfile • A text file that serves as a script to build an image • Build using the docker build command FROM node WORKDIR /app COPY package.json yarn.lock . RUN yarn install COPY src ./src CMD ["node", "src/index.js"]
  • 11. @mikesir87 Sharing Images • Once built, the image is only available locally • To share, push it to a registry using docker push • Docker Hub is the default registry • Docker EE includes the Docker Trusted Registry • Many other third-party offerings available too • Once shared, others can pull the image Source: https://landscape.cncf.io
  • 13. @mikesir87 What’s a container then? • While a container looks like a VM, it isn’t! • A container is just another process on the machine • It uses namespaces and control groups (cgroups) to provide isolation • Namespaces include network, process, user, IPC, mount, and others • To run a container, use the docker container run command
  • 15. @mikesir87 Containers vs VMs Infrastructure Host Operating System Hypervisor Guest OS Bins/Libs App 1 Guest OS Bins/Libs App 2 Guest OS Bins/Libs App 3 Infrastructure Operating System Bins/Libs App 1 Bins/Libs App 2 Bins/Libs App 3 Docker Daemon
  • 16. @mikesir87 Image Layering • Images are composed of layers of filesystem changes • Each layer can add or remove from the previous layer • Each layer’s filesystem changes are stored as a single tar file • Each command in a Dockerfile creates a new layer • Use the docker image history command to see the layers and the command that was used to create each layer
  • 17. @mikesir87 Layer contents file1 file2 file3 file4 file2 file5 file1 file2 file3 file4 file5 Layer 1 Layer 2 Merged • Layers are unioned together to make a full filesystem • Each layer can add files as needed • Files in “higher” layers replace the same file in “lower” layers • The container uses the “merged” view
  • 18. @mikesir87 What about deleted files? ● Deleted files are represented in a layer as a “whiteout” file ● Whiteout files are only used by the filesystem driver and not visible in the merged filesystem file1 file2 file3 file4 file2 file5 file1 file2 file3 file5 Layer 1 Layer 2 Merged .wh.file4 Layer 3
  • 19. @mikesir87 WARNING! Be careful what you put into images. Deleted files might not actually be gone!
  • 21. @mikesir87 Clean up as you go! ● Don’t wait until the end of the Dockerfile to “clean” up ● Chain RUN commands together to clean things as you go FROM ubuntu RUN apt-get update RUN apt-get install -y python python-pip RUN pip install awscli RUN apt-get autoremove --purge -y python-pip FROM ubuntu RUN apt-get update && apt-get install -y python python-pip && pip install awscli && apt-get autoremove --purge -y python-pip && rm -rf /var/lib/apt/lists/* Net change of image size from 512MB to 183MB (64% reduction)
  • 22. @mikesir87 Keep images tight and focused • Only install the deps/tools/packages that are necessary • Use multi-stage builds to separate build-time and run-time dependencies FROM node AS build WORKDIR /usr/src/app COPY package.json yarn.lock . RUN yarn install COPY public ./public COPY src ./src RUN yarn build FROM nginx:alpine COPY nginx.conf /etc/nginx/nginx.conf COPY --from=build /usr/src/app/build /usr/share/nginx/html Sample multi-stage build for a React app
  • 23. @mikesir87 How do you persist data?
  • 24. @mikesir87 ● Volumes provide the ability to persist/supply data ● Bind mount volumes ○ You choose where to persist the data ○ Example: -v $HOME/mysql-data:/var/lib/mysql ● Named volumes ○ Let Docker choose where to persist the data ○ Can use docker volume inspect to find actual location ○ Example: -v mysql-data:/var/lib/mysql Volumes
  • 27. @mikesir87 Docker Compose • Makes defining and running multi-container apps super easy • Uses a YAML file for configuration (docker-compose.yml) • Often included in project source repo at the root of the project • With a single command, start all containers/services for an app • Tool is bundled with Docker Desktop
  • 28. @mikesir87 Docker Networking • Think of networking in terms of communication boundaries/isolation • If two containers are on the same network, they can talk to each other • Docker runs its own DNS resolver on each network • Allows it to resolve IP addresses of other containers using “aliases” API1 Database Reverse Proxy React App API2 Cache
  • 30. @mikesir87 Container Orchestration • Orchestration provides the ability to manage the running of container workloads, often over a fleet of machines • You define the expected state (the desired state) • The system then tries to make actual state reflect expected state
  • 31. @mikesir87 Actors in Orchestration • Every orchestrator has the concept of two types of nodes • Managers • Serve as the brains of the cluster • Maintain state and schedule work • Sometimes called masters • Worker nodes • Perform the actual work, as instructed by a manager • Sometimes called agents or nodes
  • 32. @mikesir87 Various Orchestrators • Docker Swarm • Shipped with the Docker engine • Very user friendly and easy to get up and running • Satisfies most needs, though not all; built to be extensible, but takes some work • Kubernetes • Spun out of work done within Google and contributed to CNCF • Think of it more as a toolkit - so not as easy to get up and running • Very configurable and extensible • Amazon ECS • Made by Amazon Web Services and provided for free • Provides deep integration with AWS resources (IAM, ALBs, Auto-scaling, etc.)
  • 34. @mikesir87 • Containers/images are here to standardize application packaging • No longer require host configuration • Docker Compose builds on the abstraction to make multi-service apps easier • Container orchestration builds on this idea • Be mindful of how you build your images and what you include • Volumes allow data to be persisted longer than the container • Networking serves provides communication paths/isolation Recap
  • 35. @mikesir87 WARNING! Containers are NOT a silver bullet that will fix your company culture
  • 36. Thank you! Rate the session! Keep in touch! @mikesir87; mikesir87@vt.edu