0% found this document useful (0 votes)
3 views

Class-4 Containers and Docker -1

The document discusses the advantages and disadvantages of Virtual Machines and Containers, highlighting that Containers are more resource-efficient and faster to start. It explains the structure of Docker, including the concepts of images, containers, and Dockerfiles, as well as the benefits of using Containers in modern software development workflows. Additionally, it contrasts Monolithic and Microservice architectures, emphasizing the shift towards loosely coupled components in application development.

Uploaded by

Aaryan Bhagat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Class-4 Containers and Docker -1

The document discusses the advantages and disadvantages of Virtual Machines and Containers, highlighting that Containers are more resource-efficient and faster to start. It explains the structure of Docker, including the concepts of images, containers, and Dockerfiles, as well as the benefits of using Containers in modern software development workflows. Additionally, it contrasts Monolithic and Microservice architectures, emphasizing the shift towards loosely coupled components in application development.

Uploaded by

Aaryan Bhagat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Virtual Machines

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

We want a system that:

● Automatically set up (installs) all OS and extra


libraries and set up the python environment
● It is isolated
● Uses less resources Containers
● Startups quickly

5
What is a Container

Tomcat SQL Server


• Standardized packaging for software
Java .Net Static Binary
dependencies
• Isolate apps from each other
Debian Ubuntu Alpine
• Works for all major Linux distributions,
Container Container 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

• We use a simple text file, the Dockerfi le, to build the


Docker Image, which consists of an iso file and other
files.
• We run the Docker Image to get Docker
Container.

11
What is the difference between an image and container

Docker Image is a template aka a blueprint to create a running


Docker container. Docker uses the information available in
the Image to create (run) a container.

Image is like a recipe, container is like a dish.

Alternatively, you can think of an image as a class and a


container is an instance of that class.

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.

ENTRYPOINT: The ENTRYPOINT instruction is used when you


would like your container to run the same executable every time.
Usually, ENTRYPOINT is used in scenarios where you want the
container to behave exclusively as if it were the executable it's
wrapping.

CMD: The CMD sets default commands and/or parameters when a


docker container runs. CMD can be overwritten from the command
line via the docker run command. 1
3
Multiple containers from same image

How can you run multiple containers from the same image?
Yes, you could think of an image as instating a class.

Wouldn’t they all be identical?


Not necessarily. You could instantiate it with different parameters using the CMD
and therefore different containers will be different.

> docker build -t hello_world_cmd:first -f Dockerfile_cmd .


FROM ubuntu:latest
> docker run -it hello_world_cmd:first
RUN apt-get update > Hello world
ENTRYPOINT ["/bin/echo", "Hello"] > docker run -it hello_world_cmd:first Pavlos
CMD ["world"] > Hello Pavlos

14
Docker Image as Layers

When we execute the build command, the daemon reads the


Dockerfi le
and creates a layer for every command.

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

Platform Image An Image that has no parent


(Runtime Environment) - Platform images define the runtime environment,
packages and utilities necessary for containerized
application to run

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

Registry Service (Docker Hub or Docker Trusted Registry)


Cloud or server-based storage and distribution service for your
images

18
Why use Containers?

• Imagine you are building a large complex application


(e.g. Online Store)
• Traditionality you would build this using a Monolithic
Architecture

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

Simple to Develop, Test, Deploy and Scale:

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

1. Very difficult to maintain


2. One component failure will cause the whole system to fail
3. Very difficult to create the patches for monolithic architecture
4. Adapting to new technologies is challenging
5. Take a long time to startup because all the components needs to
get started

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

Browser Apps Storefront UI


HTML Catalog Module

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

Linux Source Control

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

Linux Source Control


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
software/frameworks

Production build is performed


by pulling code from source
OS Specific installation in control
every developer machine

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

Development machines only


needs Docker installed

Containers need to be setup


only once
45
Software Development Workflow (with Docker)
Windows

Linux Source Control

GitHub

Mac
Every team member moves
code to source control

Development machines only


needs Docker installed

Containers need to be setup


only once
46
Software Development Workflow (with Docker)
Windows

Build Server

Linux Source Control


Linux

GitHub

Mac
Every team member moves
code to source control Build server only needs
Docker installed

Docker images are built for a


release and pushed to
Development machines only container registry
needs Docker installed

Containers need to be setup


only once
47
Software Development Workflow (with Docker)
Windows

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

You might also like