Class-4 Containers and Docker -1
Class-4 Containers and Docker -1
Pros Cons
• Full autonomy • Uses hardware in local machine
• Very secure • Not very portable since size of
• Lower costs VMs are large
• There is an overhead associated
• Used by all Cloud providers for on
demand server instances with virtual machines
4
Wish List
5
What is a Container
MacOS, Windows
Docker
Kernel
9
What Makes Containers so Small?
Container = User Space of OS
• User space refers to all of the code in an operating system that lives
outside of the kernel
10
How to run a docker container
11
What is the difference between an image and container
12
Inside the Dockerfile
FROM: This instruction in the Dockerfile tells the daemon, which
base image to use while creating our new Docker image. In the
example here, we are using a very minimal OS image called alpine
(just 5 MB of size). You can also replace it with Ubuntu, Fedora,
Debian or any other OS image.
RUN: This command instructs the Docker daemon to run the given
commands as it is while creating the image. A Dockerfile can have
multiple RUN commands, each of these RUN commands create a
new layer in the image.
How can you run multiple containers from the same image?
Yes, you could think of an image as instating a class.
14
Docker Image as Layers
15
Image Layering
A application sandbox
- Each container is based on an image that holds
necessary config data
Container - When you launch a container, a writable layer is added
(Writable, running application) on top of the image
Layered Image 2
A static snapshot of the container
- Layer images are read-only
configuration
- Each image depends on one or more parent images
Layered Image 1
16
Some Docker Vocabulary
Docker Image
The basis of a Docker container. Represent a full application Images
How you store
your application
Docker Container
The standard unit in which the application service resides and Containers
executes How you run your
application
Docker Engine
Creates, ships and runs Docker containers deployable on a physical
or virtual, host locally, in a datacenter or cloud service provider
18
Why use Containers?
33
Monolithic Architecture
Server
HTML / REST / JSON
Storefront UI Module
Browser Apps
Catalog Module
Reviews Module
Database
Orders Module
REST / JSON
Mobile Apps
34
Monolithic Architecture
Server
HTML / REST / JSON
Storefront UI Module
Browser Apps
Catalog Module
Reviews Module
Database
Orders Module
REST / JSON Oracle
Mobile Apps
Java
35
Monolithic Architecture - Advantages
1. Simple to develop because all the tools and IDEs support the
applications by default
2. Easy to deploy because all components are packed into one
bundle
3. Easy to scale the whole application
36
Monolithic Architecture - Disadvantages
37
Applications have changed dramatically
Today
A decade ago
Apps are constantly being developed
Apps were monolithic
Built on a single stack (e.e. .NET or Build from loosely coupled components
Java) Long lived Newer version are deployed often
Deployed to a single server Deployed to a multitude of servers
38
Applications have changed dramatically
Today
A decade ago
Apps are constantly being developed
Apps were monolithic
Built on a single stack (e.e. .NET or Build from loosely coupled components
Java) Long lived Newer version are deployed often
Deployed to a single server Deployed to a multitude of servers
Data Science
Apps are being integrated with various
data types/sources and models
39
Today: Microservice Architecture
REST / JSON
Database
REST / JSON
API Service Reviews Module
Cloud Store
Mobile Apps
Orders Module
Database
REST / JSON
Recommendation
Edge Device Apps Module
Models
40
Software Development Workflow (no Docker)
Windows
Node.js
Python
Linux
Node.js
Python
Mac
Node.js
Python
OS Specific installation in
every developer machine
41
Software Development Workflow (no Docker)
Windows
Node.js
Python
Node.js GitHub
Python
Mac
Every team member moves
code to source control
Node.js
Python
OS Specific installation in
every developer machine
42
Software Development Workflow (no Docker)
Windows
Node.js
Python
Build Server
Mac
Every team member moves
code to source control Build server needs to be
Node.js
Python installed with all required
software/frameworks
43
Software Development Workflow (no Docker)
Windows
Node.js
Python
Build Server
Production / Test Servers
Linux Source Control
Linux
Linux Linux
Node.js GitHub
Python
Mac
Every team member moves
code to source control Build server needs to be
Node.js
Python installed with all required Production server needs to
softwares/frameworks be installed with all required
softwares/frameworks
Production build is performed
by pulling code from source Production server will be
control different OS version than
OS Specific installation in
development machines
every developer machine
44
Software Development Workflow (with Docker)
Windows
Linux
Mac
GitHub
Mac
Every team member moves
code to source control
Build Server
GitHub
Mac
Every team member moves
code to source control Build server only needs
Docker installed
Build Server
Production/ Test Servers
Linux Source Control
Linux
Linux Linux
GitHub
Mac
Every team member moves
code to source control Build server only needs
Docker installed Production server only needs
Docker installed
Docker images are built for a
release and pushed to Production server pulls
Development machines only container registry Docker images from
needs Docker installed container registry and runs
them
Containers need to be setup
only once
48