Containerization- A OS Level virtualization

Containerization- A OS Level virtualization

Containerization  is a lightweight alternative to full installation of OS i.e Virtual machines that involves only libraries and binary of the application which need to be run.

OS Level Virtualization (Containerization) vs. Hardware Virtualization 

  • OS Level Virtualization takes advantage of Linux kernel features such as namespace, CGroups, Apparmor , chroot. It also take less time to spin up container as only libraries and binaries are installed which are required by application. Also Container share host machine kernel.
  • Hardware level Virtualization  which required a Hypervisor and  include full installation of Virtual Machines which generally takes few minutes to spin up and also dedicated resource (cpu and memory ) are allocated to VM ‘s.

History of Containers 

  • Control groups was implemeted by google and added to Linux kernel in 2007.
  • LXC – LinuX Container comes into picture in 2009 using which containers can be implemented.
  • Docker – Most Widely used for container Management was developed in 2013 by doTcloud which was later named as Docker.
  • Rocket which similar to Docker started by CoreOs in 2014.

Benefits Of Containerization – 

  • Platform independence – Container wraps up an application with the required dependencies which can be used in physical servers, local machines or in cloud without doing any extra bit of work.
  • Resource Efficiency – Containers use less resource as they do not require a separate OS. It will consume the resources from Host OS.
  • Effective isolation – Containers help us to run our application independently from Host Os and other containers running in a server. Isolation help us to test our code in different environment.
  • Easy Scalability – A developer may run a few containers on their workstation, while this system may be scaled horizontally in staging or testing environment.
  • Operational simplicity – Containers execute application processes in isolation from underlying host OS which do not require host machine to install any software or dependencies.
  •  Decrease the time – using containers can decrease the time need for development, testing and deployment of application and services.

Docker Platform 

Docker provides the ability to package and run an application in a loosely isolated environment called a container. We can run multiple containers independent of each other.

Docker Engine 

Docker Engine is a client-server application which include –

  • Docker Server –  Daemon process of docker is running on background. it created and manages docker objects such as images, containers, networks and volumes
  • REST API – Basically the interface which communicate with daemon.
  • Docker Client – Command line interface which uses REST API to interact with docker daemon.


Docker objects –

  • Images – It is a read only template which have instructions for creating docker container. Images are made of layers.
  • Containers – Runnable instance of an images which contains the application binaries and libraries files.
  • Docker Hub Registry – Collection of public images.

Installing Docker on Ubuntu 16.04 

Add the GPG key for the official Docker repository

<pre<$curl -fsSL | sudo apt-key add –

Add the Docker repository to APT source

$sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

Update the package database

$sudo apt-get update

Install the Docker

$sudo apt-get install -y docker-ce

Check the Status of docker service – 

Check the Docker Version  –

Running First Container – 

Below command will pull busybox image from docker hub registry and will spin up a container which will echo hello world.

Running a Ubuntu container –

Below command will pull latest ubuntu image from registry and will spin up a container in interactive mode.

• -i tells Docker to connect us to the container’s stdin.
• -t tells Docker that we want a pseudo-terminal.

Exit from running container 

Running Container in the background

-d option will run container in background mode. We can list running docker container using command “docker ps ”

List Running Containers 

Currently two containers are running which can confirmed from status column.

To list containers id of running containers

To check the logs of a container 

Specify the prefix of the container id

Follow the logs in real time 

Stopping our container

  • kill – it will forcefully the stop the container immediately using KILL signal
  • stop – it will gracefully the stop the container using TERM signal.

Starting a stopped container 

Check current images 

Searching for specific image 

stars indicate the popularity of the image

Automated” images are built automatically by the Docker Hub.

Pulling an Image

docker has downloaded all the necessary layers of debian:jessie image. Jessie indicate the version tag.

Building Images With A Dockerfile

A Dockerfile is a build recipe for a Docker image. It contains a series of instructions telling Docker how an image is constructed. The docker build command builds an image from a Dockerfile.

Dockerfile example –

FROM ubuntu
RUN apt-get update
RUN apt-get install figlet

FROM indicates the base image for our build.

Each RUN line will be executed by Docker during the build.

Using image and viewing history

Leave a Reply

Your email address will not be published. Required fields are marked *