SlideShare a Scribd company logo
Docker
DevOps with Containers
Agenda
Monday Tuesday Thursday Friday
Morning VMs vs Containers
Docker Overview
Install Docker
Docker commands
Running containers
Q&A
Recap
Docker Images
Docker Networks
Q&A
Dockerfiles review
Docker Storage
Q&A
Recap
Docker Compose
Kubernetes
Afternoon Videos
Labs
Reading
Videos
Labs
Reading
Videos
Labs
Reading
Videos
Labs
Reading
Topics to review before we start
● Linux command line
○ ls, ls -R
○ date
○ grep, cat
○ type
○ man
● Filesystem
○ mkdir, chmod, chown, pwd
○ permissions
○ cd, touch
● Pipes
● SSH
● Shell alias
● Editor: vi
● Superuser
● nginx
● git
Why Containers?
Sharing Compute Resources
Physical Server
Also: bare-metal server
Fixed processor, memory, network,
storage
Operating system hosts applications
with their dependencies
Single tenant (owner)
Virtual Server
Also: virtual machine (VM)
Emulation of a physical computer
Hardware is shared by multiple
VMs
Each VM runs an operating system
Multiple tenants (owners)
Container
Operating system is shared
Applications are packaged as
container images with their
dependencies and isolated at
runtime (Docker)
Lower overhead than VMs
Virtual Machines vs. Containers
State of the Art
● Applications
○ run as multiple instances of small containers
○ managed by “orchestrators” like Kubernetes
● Databases
○ special performance and storage requirements
○ run as virtual machines
Docker Overview
Docker
● Open Source Container engine
● A ”Docker image” is an application containerized using
docker
● Docker is also the Company behind docker
● A Docker image is pushed to a Registry, and pulled to
start a container
From Docker image to container
Image
Dockerfile Container Container
Developer Operator
writes
docker build
docker push
Docker Registry
docker pull
docker run docker run
Docker Overview (13 min)
DevOps and Containers
Containers
Containers
Containers
Containers
What is DevOps?
Articles to read
What is a container
Containers as the foundation for DevOps collaboration
Docker and the Three Ways of DevOps
Exercise
Write down three benefits of DevOps and how containers make it easier to
achieve them.
Docker Commands
● Follow instructions at https://docs.docker.com/get-docker/
○ Install Docker using the convenience script
● Add your user to the docker group
○ sudo adduser <username> docker
● Log out and log in again
● Check Docker version
○ docker version
● Run a hello world command
○ docker run hello-world
Install Docker on your Virtual Machine
The anatomy of a Linux process
● The executable - the binary file located in the file system
○ which docker; which vim; file $(which cat)
● The process ID and hierarchy
○ ps; ps -elf; pstree <user>; pstree -pa; docker ps; docker -as
● STDIN, STDOUT, STDERR and redirections
○ {STDIN} → Process → STDOUT + STDERR
○ [process] < [file] (stdin_input)
○ [process] > [file] (stdout_output)
○ [process] 2> [file] (stderr_output)
● Environment variables - Executables can read them.
○ printenv; export
Common Binaries to use
● Nginx: web server to serve static sites or to load balance HTTP requests to
applications
● Redis: in-memory database, for storing simple data structures as key/value
pairs
● MySQL: relational database, frequently used as backend for websites (e.g.
Wordpress)
● PostgreSQL: relational database like MySQL, older, feature rich
● Ansible, Chef, Puppet: you write configuration "as code" and the tool applies
it automatically on servers
● Ubuntu, CentOS, Fedora, Debian, Alpine: Linux distributions
Docker commands
● docker run <image>
○ If image not found locally, downloads the latest image from Registry.
○ Starts container with a Container ID != Image name
○ Can start the container in detached mode
○ Can setup port mapping to access the Container
● docker ps [-as]
○ Lists running containers
● docker images
● docker exec <container> <command>
○ Runs a command inside a container
● ...
Docker Commands (12 min)
Katacoda Scenario; KodeKloud Lab [CouseLink]
● Start and stop containers
● Pull and remove images
● Inspect what an image is made of
Docker CLI Reference
Lab 1: Docker Basic Commands
Docker Run (9 min)
Lab 2: Docker Run Commands
Katacoda Scenario; KodeKloud Lab
● Inspect running containers
● Configure port mappings
● Lookup image usage details on Docker Hub
Docker CLI Reference
Environment Variables (2 min)
Recap Day 1
Why to use containers
● Containerization provides consistent environments. Applications behave the
same on the developer's workstation and in production deployments.
● Containerized applications are isolated from other applications also when
containers of different applications run on the same server.
● Container images include software dependencies of the application like
programming language runtimes or software libraries.
● Containers are more lightweight than physical servers and virtual machines.
This reduces costs and enables faster updates of applications.
● Many tools are available to build and run containerized applications. This
week, we get to know Docker, Docker Compose, and Kubernetes.
What happens when Docker starts a container
1. Look for the image in the local cache
2. If not found, look for the image in the remote image repository
3. When needed, pull the image from the repository to the local cache
4. Extract all the layers of the container image
5. Create a layer on top which will be used for changes by the new container
6. Give the container its own internal IP address and connect it to the network
7. If requested, establish port mappings from the host to the container
8. Start the command specified in Dockerfile within the container environment
Docker Commands Cheat Sheet
● docker help ps|run|exec|stop|rm|images|rmi|inspect # get quick help
● docker ps [-q] [-a] # list containers, also stopped with -a, only IDs with -q
● docker run [-d] [--name name] [-e name=value] [-p hostport:containerport] image[:tag]
● docker exec -it container /bin/bash # open shell in running container
● docker stop container… # stop running containers
● docker rm container… # delete stopped containers
● docker rm $(docker ps -q -a) # delete all existing containers, all have to be stopped
● docker images [-q] # list local container images, only IDs with -q
● docker rmi image… # delete local container images
● docker inspect container|image # inspect details about containers or images
Docker Images
Docker Images (7 min)
Lab 4: Docker Images
Katacoda Scenario; KodeKloud Lab
● Check the size of images
● Build images with Dockerfiles
CMD vs. ENTRYPOINT (7 min)
Lab 5: CMD vs. ENTRYPOINT
KodeKloud Lab
● Inspect Dockerfiles
Build Your Own Image
Short Quiz to Warm Up
https://forms.gle/X38MDMw3PXYZcq398
Extensive documentation about Dockerfile is available on the Docker site:
https://docs.docker.com/engine/reference/builder/. You may need this reference
also for the assignment on the next slide.
How to build container images
1. Create a new Dockerfile in your application source tree
2. Specify the base image (FROM)
3. Install dependencies with the Linux distro's package manager (RUN)
4. Define the directory where the application will run (WORKDIR)
5. Copy the dependency manifest, e.g. package.json, into the image (COPY)
6. Install direct dependencies of your application e.g. with npm (RUN)
7. Copy the source code into the image (COPY)
8. Define on which port the application will be listening (EXPOSE)
9. Specify the command to be run when the container starts (CMD)
Assignment: Build Your Own Image
Take an existing Node.js app and dockerize it
Download the source code of the app to your instance with this command:
curl -s https://lanfranchi.ch/fabio/dockerfile-assignment-1.tar.gz | tar -xzvf -
● The code is extracted to a subdirectory named dockerfile-assignment-1.
● Start by reading the detailed instructions in the Dockerfile.
● Flesh out the Dockerfile. Build it. Test it. Run it.
● Expect this to be iterative. Rarely do I get it right the first time.
● Use the Alpine version of the official 'node' 16.x image.
● Expected result is a web site.
Container Registry
● Where to store Docker Images
● Can be public or private
● Hosted or Self-hosted
● Organized by Repositories ( == app name), ordered by tags ( == versions)
Docker Registry (5 mins)
A Hoster Docker Registry
Docker Hub Account and upload
● Sign up with Docker Hub: https://hub.docker.com
● Use e.g. powercoder<your name> as Docker ID
● Log in with your Docker Hub credentials on your workstation: docker login
● Create a repository in Docker Hub
● Upload your image
Recap Day 2
Show your Docker image in DockerHub
Docker Networking
A few useful Linux commands
● ip address; ip link
● ping <ip>
● telnet <ip> <port>
● netstat -nat ; netstat -nat | grep LISTEN ; netstat -nat | grep :<port>
● curl http://<ip>:<port>
● curl [-v] http://<url>
● touch <file>; cat <file>; nano <file>
● cat <file> | grep [-i] <text> | wc
● echo << EOF
Docker networks
‘docker networks ls’
● bridge (default) = Containers get an IP and can communicate with other
containers in the bridge.
○ Expose ports externally via mapping.
● none = Containers do not get any IP and cannot communicate with
others.
● host = Containers shares the network of the server. All containers share
the same IP address of the host.
○ All ports are reachable on the server IP.
● custom bridge = As the default bridge, but controls the IP subnet and has
built-in DNS.
Multiple ports on Containers
nginx :80 nginx :80
host_ip: 10.10.1.1
bridge 172.16.0.12
172.16.0.11
-p 8080:80
-p 8090:80
nginx :8080 nginx :8090
host_ip: 10.10.1.1
host
Docker Networking (5 min)
Lab 6: Docker Networking
Katacoda Scenario; KodeKloud Lab
● Configure the network of containers
● Connect two containers on a user-defined network
Docker Storage
Docker Storage
● Writable layer = Changes are deleted after container is stopped. Copy-
on-Write.
● Volume = Changes are permanent after container is stopped. In
/var/lib/docker/volumes. Managed by Docker.
● Bind Mount= Changes are permanent after container is stopped.
Managed by the host Server. Can be in any mount point.
● Tempfs = Changes are deleted after container is stopped. Paths outside
of the Writable layer (i.e. /app/data)
Docker Storage
● Volumes and Bind Mounts for
○ Share data between containers
○ Share configuration files from host to container
○ Write logs to external storage
Docker Storage (12 min)
Lab 7: Docker Storage
Katacoda Scenario; Katacoda Scenario
● Use persistent storage for a database container
Recap Day 3
Quiz Time
Docker Compose
Introduction to YAML (8 min)
Lab 8: Introduction to YAML
YAML Quiz
About Docker compose
Deploy application stacks in a single run
Application stack = Application made of several containers
docker build -t admin-web -f admin-web/Dockerfile
docker build -t users-web -f users-web/Dockerfile
docker volume create sql_vol
docker run -d -p 8080:80 -name admin-web admin-web
docker run -d -p 80:80 -name users-web users-web
docker run -d -v sql_vol:/var/mysql -name db mysql
version:2
services:
admin-web:
build: admin-web/
ports:
- “8080:80”
users-web:
build: users-web/
ports:
- “80:80”
db:
image: db
volumes:
- sql_vol:/var/mysql
volumes:
sql_vol: {}
docker-compose up
docker-compose down
Docker Compose (18 min)
Lab 9: Docker Compose
Katacoda Scenario
● Run an application consisting of two containers
● Create a docker-compose.yml file (in format version 1)
Kubernetes
What Kubernetes does
Manages a group of servers that run containers = Nodes
Deploys application stacks on the cluster = Pod
Manages and keeps the Pods healthy
Cluster = Master + Nodes
An Introduction to Kubernetes
https://www.jeremyjordan.me/kubernetes/
Container Orchestration (4 min)
Kubernetes (6 min)

More Related Content

Similar to Powercoders · Docker · Fall 2021.pptx

Introduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" EditionIntroduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" Edition
Jérôme Petazzoni
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow
 
Docker
DockerDocker
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
InfluxData
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
corehard_by
 
How to _docker
How to _dockerHow to _docker
How to _docker
Abdur Rab Marjan
 
The internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesThe internals and the latest trends of container runtimes
The internals and the latest trends of container runtimes
Akihiro Suda
 
Docker Intro
Docker IntroDocker Intro
Docker Intro
Ruben Taelman
 
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New YorkIntroduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New York
Jérôme Petazzoni
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
CloudHero
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
Roman Rodomansky
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
Philip Zheng
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
Paul Chao
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
Araf Karsh Hamid
 
Docker+java
Docker+javaDocker+java
Docker+java
DPC Consulting Ltd
 
Docker up and Running For Web Developers
Docker up and Running For Web DevelopersDocker up and Running For Web Developers
Docker up and Running For Web Developers
BADR
 
Docker Up and Running for Web Developers
Docker Up and Running for Web DevelopersDocker Up and Running for Web Developers
Docker Up and Running for Web Developers
Amr Fawzy
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
Guido Schmutz
 
DOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDESDOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDES
MuhammadAhmed651877
 
Docker, but what it is?
Docker, but what it is?Docker, but what it is?
Docker, but what it is?
Julien Maitrehenry
 

Similar to Powercoders · Docker · Fall 2021.pptx (20)

Introduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" EditionIntroduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" Edition
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
Docker
DockerDocker
Docker
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
How to _docker
How to _dockerHow to _docker
How to _docker
 
The internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesThe internals and the latest trends of container runtimes
The internals and the latest trends of container runtimes
 
Docker Intro
Docker IntroDocker Intro
Docker Intro
 
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New YorkIntroduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New York
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Docker+java
Docker+javaDocker+java
Docker+java
 
Docker up and Running For Web Developers
Docker up and Running For Web DevelopersDocker up and Running For Web Developers
Docker up and Running For Web Developers
 
Docker Up and Running for Web Developers
Docker Up and Running for Web DevelopersDocker Up and Running for Web Developers
Docker Up and Running for Web Developers
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
DOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDESDOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDES
 
Docker, but what it is?
Docker, but what it is?Docker, but what it is?
Docker, but what it is?
 

Recently uploaded

Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 

Recently uploaded (20)

Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 

Powercoders · Docker · Fall 2021.pptx

  • 2. Agenda Monday Tuesday Thursday Friday Morning VMs vs Containers Docker Overview Install Docker Docker commands Running containers Q&A Recap Docker Images Docker Networks Q&A Dockerfiles review Docker Storage Q&A Recap Docker Compose Kubernetes Afternoon Videos Labs Reading Videos Labs Reading Videos Labs Reading Videos Labs Reading
  • 3. Topics to review before we start ● Linux command line ○ ls, ls -R ○ date ○ grep, cat ○ type ○ man ● Filesystem ○ mkdir, chmod, chown, pwd ○ permissions ○ cd, touch ● Pipes ● SSH ● Shell alias ● Editor: vi ● Superuser ● nginx ● git
  • 5. Physical Server Also: bare-metal server Fixed processor, memory, network, storage Operating system hosts applications with their dependencies Single tenant (owner)
  • 6. Virtual Server Also: virtual machine (VM) Emulation of a physical computer Hardware is shared by multiple VMs Each VM runs an operating system Multiple tenants (owners)
  • 7. Container Operating system is shared Applications are packaged as container images with their dependencies and isolated at runtime (Docker) Lower overhead than VMs
  • 8. Virtual Machines vs. Containers
  • 9. State of the Art ● Applications ○ run as multiple instances of small containers ○ managed by “orchestrators” like Kubernetes ● Databases ○ special performance and storage requirements ○ run as virtual machines
  • 11. Docker ● Open Source Container engine ● A ”Docker image” is an application containerized using docker ● Docker is also the Company behind docker ● A Docker image is pushed to a Registry, and pulled to start a container
  • 12. From Docker image to container Image Dockerfile Container Container Developer Operator writes docker build docker push Docker Registry docker pull docker run docker run
  • 16. Articles to read What is a container Containers as the foundation for DevOps collaboration Docker and the Three Ways of DevOps
  • 17. Exercise Write down three benefits of DevOps and how containers make it easier to achieve them.
  • 19. ● Follow instructions at https://docs.docker.com/get-docker/ ○ Install Docker using the convenience script ● Add your user to the docker group ○ sudo adduser <username> docker ● Log out and log in again ● Check Docker version ○ docker version ● Run a hello world command ○ docker run hello-world Install Docker on your Virtual Machine
  • 20. The anatomy of a Linux process ● The executable - the binary file located in the file system ○ which docker; which vim; file $(which cat) ● The process ID and hierarchy ○ ps; ps -elf; pstree <user>; pstree -pa; docker ps; docker -as ● STDIN, STDOUT, STDERR and redirections ○ {STDIN} → Process → STDOUT + STDERR ○ [process] < [file] (stdin_input) ○ [process] > [file] (stdout_output) ○ [process] 2> [file] (stderr_output) ● Environment variables - Executables can read them. ○ printenv; export
  • 21. Common Binaries to use ● Nginx: web server to serve static sites or to load balance HTTP requests to applications ● Redis: in-memory database, for storing simple data structures as key/value pairs ● MySQL: relational database, frequently used as backend for websites (e.g. Wordpress) ● PostgreSQL: relational database like MySQL, older, feature rich ● Ansible, Chef, Puppet: you write configuration "as code" and the tool applies it automatically on servers ● Ubuntu, CentOS, Fedora, Debian, Alpine: Linux distributions
  • 22. Docker commands ● docker run <image> ○ If image not found locally, downloads the latest image from Registry. ○ Starts container with a Container ID != Image name ○ Can start the container in detached mode ○ Can setup port mapping to access the Container ● docker ps [-as] ○ Lists running containers ● docker images ● docker exec <container> <command> ○ Runs a command inside a container ● ...
  • 24. Katacoda Scenario; KodeKloud Lab [CouseLink] ● Start and stop containers ● Pull and remove images ● Inspect what an image is made of Docker CLI Reference Lab 1: Docker Basic Commands
  • 26. Lab 2: Docker Run Commands Katacoda Scenario; KodeKloud Lab ● Inspect running containers ● Configure port mappings ● Lookup image usage details on Docker Hub Docker CLI Reference
  • 29. Why to use containers ● Containerization provides consistent environments. Applications behave the same on the developer's workstation and in production deployments. ● Containerized applications are isolated from other applications also when containers of different applications run on the same server. ● Container images include software dependencies of the application like programming language runtimes or software libraries. ● Containers are more lightweight than physical servers and virtual machines. This reduces costs and enables faster updates of applications. ● Many tools are available to build and run containerized applications. This week, we get to know Docker, Docker Compose, and Kubernetes.
  • 30. What happens when Docker starts a container 1. Look for the image in the local cache 2. If not found, look for the image in the remote image repository 3. When needed, pull the image from the repository to the local cache 4. Extract all the layers of the container image 5. Create a layer on top which will be used for changes by the new container 6. Give the container its own internal IP address and connect it to the network 7. If requested, establish port mappings from the host to the container 8. Start the command specified in Dockerfile within the container environment
  • 31. Docker Commands Cheat Sheet ● docker help ps|run|exec|stop|rm|images|rmi|inspect # get quick help ● docker ps [-q] [-a] # list containers, also stopped with -a, only IDs with -q ● docker run [-d] [--name name] [-e name=value] [-p hostport:containerport] image[:tag] ● docker exec -it container /bin/bash # open shell in running container ● docker stop container… # stop running containers ● docker rm container… # delete stopped containers ● docker rm $(docker ps -q -a) # delete all existing containers, all have to be stopped ● docker images [-q] # list local container images, only IDs with -q ● docker rmi image… # delete local container images ● docker inspect container|image # inspect details about containers or images
  • 34. Lab 4: Docker Images Katacoda Scenario; KodeKloud Lab ● Check the size of images ● Build images with Dockerfiles
  • 36. Lab 5: CMD vs. ENTRYPOINT KodeKloud Lab ● Inspect Dockerfiles
  • 37. Build Your Own Image
  • 38. Short Quiz to Warm Up https://forms.gle/X38MDMw3PXYZcq398 Extensive documentation about Dockerfile is available on the Docker site: https://docs.docker.com/engine/reference/builder/. You may need this reference also for the assignment on the next slide.
  • 39. How to build container images 1. Create a new Dockerfile in your application source tree 2. Specify the base image (FROM) 3. Install dependencies with the Linux distro's package manager (RUN) 4. Define the directory where the application will run (WORKDIR) 5. Copy the dependency manifest, e.g. package.json, into the image (COPY) 6. Install direct dependencies of your application e.g. with npm (RUN) 7. Copy the source code into the image (COPY) 8. Define on which port the application will be listening (EXPOSE) 9. Specify the command to be run when the container starts (CMD)
  • 40. Assignment: Build Your Own Image Take an existing Node.js app and dockerize it Download the source code of the app to your instance with this command: curl -s https://lanfranchi.ch/fabio/dockerfile-assignment-1.tar.gz | tar -xzvf - ● The code is extracted to a subdirectory named dockerfile-assignment-1. ● Start by reading the detailed instructions in the Dockerfile. ● Flesh out the Dockerfile. Build it. Test it. Run it. ● Expect this to be iterative. Rarely do I get it right the first time. ● Use the Alpine version of the official 'node' 16.x image. ● Expected result is a web site.
  • 41. Container Registry ● Where to store Docker Images ● Can be public or private ● Hosted or Self-hosted ● Organized by Repositories ( == app name), ordered by tags ( == versions)
  • 43. A Hoster Docker Registry
  • 44. Docker Hub Account and upload ● Sign up with Docker Hub: https://hub.docker.com ● Use e.g. powercoder<your name> as Docker ID ● Log in with your Docker Hub credentials on your workstation: docker login ● Create a repository in Docker Hub ● Upload your image
  • 45. Recap Day 2 Show your Docker image in DockerHub
  • 47. A few useful Linux commands ● ip address; ip link ● ping <ip> ● telnet <ip> <port> ● netstat -nat ; netstat -nat | grep LISTEN ; netstat -nat | grep :<port> ● curl http://<ip>:<port> ● curl [-v] http://<url> ● touch <file>; cat <file>; nano <file> ● cat <file> | grep [-i] <text> | wc ● echo << EOF
  • 48. Docker networks ‘docker networks ls’ ● bridge (default) = Containers get an IP and can communicate with other containers in the bridge. ○ Expose ports externally via mapping. ● none = Containers do not get any IP and cannot communicate with others. ● host = Containers shares the network of the server. All containers share the same IP address of the host. ○ All ports are reachable on the server IP. ● custom bridge = As the default bridge, but controls the IP subnet and has built-in DNS.
  • 49. Multiple ports on Containers nginx :80 nginx :80 host_ip: 10.10.1.1 bridge 172.16.0.12 172.16.0.11 -p 8080:80 -p 8090:80 nginx :8080 nginx :8090 host_ip: 10.10.1.1 host
  • 51. Lab 6: Docker Networking Katacoda Scenario; KodeKloud Lab ● Configure the network of containers ● Connect two containers on a user-defined network
  • 53. Docker Storage ● Writable layer = Changes are deleted after container is stopped. Copy- on-Write. ● Volume = Changes are permanent after container is stopped. In /var/lib/docker/volumes. Managed by Docker. ● Bind Mount= Changes are permanent after container is stopped. Managed by the host Server. Can be in any mount point. ● Tempfs = Changes are deleted after container is stopped. Paths outside of the Writable layer (i.e. /app/data)
  • 54. Docker Storage ● Volumes and Bind Mounts for ○ Share data between containers ○ Share configuration files from host to container ○ Write logs to external storage
  • 56. Lab 7: Docker Storage Katacoda Scenario; Katacoda Scenario ● Use persistent storage for a database container
  • 60. Lab 8: Introduction to YAML YAML Quiz
  • 61. About Docker compose Deploy application stacks in a single run Application stack = Application made of several containers docker build -t admin-web -f admin-web/Dockerfile docker build -t users-web -f users-web/Dockerfile docker volume create sql_vol docker run -d -p 8080:80 -name admin-web admin-web docker run -d -p 80:80 -name users-web users-web docker run -d -v sql_vol:/var/mysql -name db mysql version:2 services: admin-web: build: admin-web/ ports: - “8080:80” users-web: build: users-web/ ports: - “80:80” db: image: db volumes: - sql_vol:/var/mysql volumes: sql_vol: {} docker-compose up docker-compose down
  • 63. Lab 9: Docker Compose Katacoda Scenario ● Run an application consisting of two containers ● Create a docker-compose.yml file (in format version 1)
  • 65. What Kubernetes does Manages a group of servers that run containers = Nodes Deploys application stacks on the cluster = Pod Manages and keeps the Pods healthy Cluster = Master + Nodes
  • 66. An Introduction to Kubernetes https://www.jeremyjordan.me/kubernetes/

Editor's Notes

  1. Image a new application needs running: slow to deploy new servers During the night: resources are not used optimally Imagine a Server breaks: Maintenance and operations are slow (fix, repair)
  2. Image a new application needs running: fast to deploy new servers During the night: The HW is used more, because it is shared. During the day: peak use of resources cause contention Imagine a Server breaks: Easy migration (?) Problem: Operation, still each VM is unique. Hard to track dependencies (app needs to build the whole stack up to the OS) Compute resources wasted on running the same OS multiple times. Multiple versions (?) OSs to patch slow (fix, repair
  3. Docker is not the only one, there are other Container engines, like lxd.
  4. All applications are based on the same OS: Linux! No dependencies are installed on the Host OS, they are packaged in the application The Application cannot require tuning the OS - No customization VMs are good for isolation Containers are smaller, easier to move
  5. Micro Services architecture
  6. Why do we need an Orchestrator Applications made of several Containers Monitor and restart containers that failed Determine where to run containers The Developer and the Operator can be the same person
  7. Why do we need to log out and in again? > Changes to the user membership apply on new login
  8. EnvVars = A way to pass configuration information
  9. Why do we have a Containerd ID and not the Image name? What are they different?
  10. Why do we have a Containerd ID and not the Image name? What are they different?