Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CONTAINERIZATION

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

CONTAINERIZATION

(Containers-Intuition, Definition and Concepts, Dockers,


Docker objects, Docker Architecture)
D R. JA SM EE T SIN G H,
A SSI STANT P RO F ES SOR,
C SE D, T IE T
CONTAINERIZATION- INTUITION
 Cloud-native is the newest application development approach for
building scalable, dynamic, hybrid cloud-friendly software.
Container technology is a powerful part of that approach.
Container technology is analogous to modern shipping technology.
The modern shipping industry standardized a set of container
sizes, so no matter what item is shipped, the container size remains
the same.
Standardization significantly improves shipping efficiency.
Logistics staff select container transport options such as ships,
planes, trains, and trucks, based on the container’s size and the
client’s delivery needs.
Digital container technology is similar.
What is a Container?
Containers solve the problem of making software portable so that applications can run on
multiple platforms.
A container, powered by the containerization engine, is a standard unit of software that
encapsulates the application code, runtime, system tools, system libraries, and settings
necessary for programmers to build, ship, and run applications efficiently.
 Operations and underlying infrastructure issues are no longer blockers.
We can quickly move applications from your laptop to a testing environment, from a staging
environment to a production environment, from a physical machine to a virtual machine, or a
private cloud or public cloud, and always know that your application will work correctly.
A container can be small, just tens of megabytes, and developers can almost instantly start
containerized applications.
A Container
Why use Containers?
There are a number of development and deployment challenges organizations
encounter with traditional computing environments (as listed below). Containers enable
organizations to overcome these challenges.
Challenges Traditional Computing Environments
Isolation and Allocation No way to define resource boundaries for apps in physical server.
Server Utilization Not optimal because server tend to be either over-utilized or under-utilized.
Provisioning and Costs Requires long periods for provisioning resources and expensive maintenance costs.
Performance Constrained during peak loads
Portability Applications are not portable across multiple environment and operating systems.
Scalability Limited scalability
Automation Difficult to implement for multiple platforms.
Container Characteristics
 The container engine virtualizes the operating
system.

 A container is light-weight, fast, isolated,


portable and secure.

 Require less memory.

Binaries, libraries within container enable apps


to run.

One machine can host multiple containers.


Container Characteristics (Contd…..)
 Containers are platform-independent and
can run on the cloud, desktop, and on-
premises.
Containers being operating system-
independent, run on Windows, Linux, or
Mac OS.
Containers are also programming
language and IDE independent—whether
you are running Python, Node, Java, or
other languages.
Containers Benefits
Containers enable organizations to:

1. Quickly create applications using automation.

2. Lower deployment time and costs.

3. Improve resource utilization (CPU, memory)

4. Port across different environments.

5. Support next-gen applications (microservices)


Container Challenges
1. Security impacted if operating system affected.

2. Difficult to manage thousands of containers.

3. Complex to migrate legacy projects to container technology.

4. Difficult to choose right-size containers for specific scenarios.


Popular Container Vendors
1. Docker: Docker is a robust platform and the most popular container platform today.
2. Podman: Podman is a daemon-less container engine that is more secure than
Docker.
3. LXC: Developers often prefer LXC for data-intensive applications and operations.

4. Vagrant: Vagrant offers the highest levels of isolation on the running physical
machine.
What is Docker?
 Available since 2013, docker is an open platform, or engine for developing, shipping,
and running applications as containers.
Docker became popular with developers because of its
 simple architecture,
 massive scalability,
 and portability on multiple platforms, environments, and locations.
 Docker is written in the Go programming language
Docker uses Linux kernel features to deliver its functionality.
Docker also uses namespaces to provide an isolated workspace called the container.
Docker creates a set of namespaces for every container and each aspect runs in a
separate namespace with access limited to that namespace.
Docker (Contd…)
Docker isolates applications from infrastructure, including the hardware, the
operating system, and the container runtime.
Docker Container Creation Process
 The steps to create and run containers are:
1. Create a Dockerfile.
2. Use the Dockerfile to create a container image.
3. Use the container image to create a running container.
Docker Objects
Docker File
 A Dockerfile is a text file that contains instructions needed to create an image.
 We can create a Dockerfile using any editor from the console or terminal.
 Some of the essential instructions that Docker provides:
1. A Dockerfile must always begin with a FROM instruction that defines a base
image. Often the base image is from a public repository, like an operating system or a
specific language like Go or Node.js.
2. The RUN instruction executes commands.
3. The CMD instruction defines a default command for execution. A Dockerfile should
have only one CMD instruction. If the Dockerfile has several CMD instructions, only
the last CMD instruction will take effect.
Docker File Example – Print Hello
message in container
A simple Node.js application that we will FROM node:9.4.0-alpine
run in a container. The app will print a hello COPY app.js .
message along with the hostname. The
following files are needed to run the app in a COPY package.json .
container: RUN npm install &&\
1. app.js is the main application, which apk update &&\
simply replies with a hello world
apk upgrade
message.
EXPOSE 8080
2. package.json defines the dependencies of
the application. CMD node app.js
3. Dockerfile defines the instructions
Docker uses to build the image.
Docker File Example – Print Hello
message in container (Contd….)
The FROM instruction initializes a new build stage and specifies the base image that
subsequent instructions will build upon.

The COPY command enables us to copy files to our image.

The RUN instruction executes commands.

The EXPOSE instruction exposes a particular port with a specified protocol inside a
Docker Container.

The CMD instruction provides a default for executing a container, or in other words, an
executable that should run in your container.
Docker Images
 A Docker Image is a read-only template with
instructions for creating a Docker container.
 The Dockerfile provides instructions to build the
image.
 Each Docker instruction creates a new layer in the
image.
 When we change the Dockerfile and rebuild the
image, the Docker engine only rebuilds the
changed layers.  When we instantiate this image, we
 Images can share these layers, which saves a lot get a running container.
of disk space as well as network bandwidth when  At this point, a writeable container
sending and receiving images. layer is placed on top of the read-only
layers.
Naming Docker Images
 An image name has a unique format that
consists of three parts:
 the hostname,
 the repository,
 and the tag.
The hostname identifies the image
registry.
A repository is a group of related container
images.
The tag provides information about a
specific version or variant of an image.
Docker Images Creation
Docker images are created from
DockerFile using docker build command
(as shown in Figure).
 The created images can be pushed in a
configured registry using docker push
command (Example: docker push my-
app:v1)
 The pushed images can be retrieved from
a configured registry using docker pull
command (Example: docker pull my-
app:v1).
 docker images command lists all
images, repositories, tags, and sizes.
Docker Container
A Docker container
 is a runnable instance of an image.

 We can use the Docker API or CLI to create, start, stop, or delete an image.

 We can connect to multiple networks, attach storage to the container.

 Docker keeps containers well isolated from each other and their host machine.
Docker Container vs. Docker Images
Docker Networks, Storage & Plugins
Docker Hub
 Docker Hub is the public repository of Docker images that calls itself the “world’s
largest library and community for container images.”

It holds over 100,000 container images sourced from commercial software
vendors, open-source projects, and individual developers.

 It includes images that have been produced by Docker, Inc., certified images belonging
to the Docker Trusted Registry, and many thousands of other images.
Docker Containers vs. Virtual Machines (VMs)
 Containers and virtual machines have similar resource isolation and allocation benefits, but
function differently because containers virtualize the operating system instead of hardware.
Containers are more portable and efficient.
Docker Containers vs. Virtual Machines (VMs)
Containers are an abstraction at the app
layer that packages code and
dependencies together.
Multiple containers can run on the same
machine and share the OS kernel with
other containers, each running as
isolated processes in user space.
Containers take up less space than VMs
(container images are typically tens of
MBs in size), can handle more
applications and require fewer VMs and
Operating systems.
Docker Containers vs. Virtual Machines (VMs)
• Virtual machines (VMs) are an
abstraction of physical hardware
turning one server into many servers.
• The hypervisor allows multiple VMs to
run on a single machine.
• Each VM includes a full copy of an
operating system, the application,
necessary binaries and libraries -
taking up tens of GBs.
• VMs can also be slow to boot.
Docker Architecture

You might also like