DevOps Tools Docker Online Training

DOCKER Tutorials

Devops Tools Online Course syllabus

GIT      Jenkins     Puppet       Ansible      Docker      Kubernetes      Selenium      Nagios      Maven   

 

MODULE 5

Introduction
What is Docker?
what is container?
Containerization vs. Virtualization
Docker Fundamentals
Docker Architecture
Docker Installation on Linux
Understanding the Docker components
Working with Images
Docker Containers
Docker Networking
Docker Files
Docker Volumes
Creating our own images
Deploying the docker container throlugh Jenkins
DOCKER TOOLS
Docker machine
Docker compose
Docker swarm
Kitematic setup

Docker  Intoduction Video
 

What is docker? 

Docker is a container technology launched in 2013 as an open source Docker Engine.   Dockers technology is unique because it focuses on the requirements of developers and system operators to separate application dependencies from the infrastructure.  In simple Docker is nothing but a containerisation software.  Meaning, to work with containers, to launch the containers, to run the containers, we need Docker software.  And Docker was initially developed for Linux systems and as it was success for Linux environments, now Docker functionality was extended at available for windows servers as well. 

 

VMs VS CONTAINERS

     In this video we will try to analyse the differences between the VMs and Containers.  In VMS virtualisation is done to the hardware, where as in Containers virtualisation is done at OS level.   What does it mean?  Let us see.  To understand this, let’s see the architecture of both in detail. 

 

       Let’s first look into the architecture of VMs.  In VMs there is a server, above this there is a host operating system.  And then we have a hypervisor.  We need this hypervisor to launch the VMs or to run multiple VMs in isolation.  And what is a hypervisor?  It’s nothing but a software with which you can launch your VMs, allocate resources to your VMs.  So, the examples of hypervisor software are Oracle Virtual Box, VMware, VM workstation and so on.  So, we need a hypervisor to be installed in the host OS.  Above this we can launch any number of VMs of course depends on the resources of the host OS.  Now every VM will have its own operating system which is referred as guest OS.  And this guest OS sits above the host OS.  And because, Every VM will have its own Operating System, it just works like a normal machine.  It can start, it can shut down, it can reboot, it can do everything.  It can work like a normal machine.  And because every VM has got its own OS, its heavy and it works a little slower.  Because it needs to launch the Operating System and all, it works a bit slow.  Also because every VM has its own VS it consumes more system resources of the host.  And that is how a VM works

 
 

 And you can have Virtual Machine VM of any Operating System.  The guest Operating System is the independent of the host Operating System.  Meaning we can have multiple Operating Systems running the same system using this VMs.  Let’s suppose our host Operating System is Windows, we can have our VMs of Linux VMs, or Mac any VMs.  So that is possible, meaning we can run multiple Operating Systems on the same host.  But if VM number increases much, means running too many VMs degrades the performance.  So that is the architecture and the benefits of the VM in simple. 

     Now let’s come to the architecture of Containers.  In Containers we have a server, host Operating System, above this we need a Docker Engine.  Docker Engine is nothing but a Containerisation software.  Docker daemon nothing but  Docker should be installed to run your Containers.  And if you look into each Container in detail, Container will not have its own Operating System.  It will just share the Operating System of the host.

 

 So, if we are talking about the Operating System of the host, if you are talking about the Container, they don’t have their own Operating System.  They will share the Operating System of the host.  So, if you are talking about the Linux Containers, yes, they will not have their own Kernel.  They will share the Kernel of the host OS.  And because they don’t have a separate Operating System, they are light weight and works really very faster.  And because we need not allocate the resources ,means there is no separate Operate System , resource consumption is also very less when compared to the VMs.  This is the difference between the Containers and VMs.  And the point to note here is in VMs, to run the VMs our hardware should support.  You might have noticed in your systems, we need to go to bias, enable the technology to run VMs.  Where as that is not the case with Containers.   

 

 Meaning in VMs your hardware should support to run the the VMs.  Whereas in Containers, you have nothing to do with the hardware.  Meaning in VMs, virtualisation is done to the hardware whereas in Containers virtualisation is done at the OS level, hence you need not have any support from the hardware.  So these are the differences between VMs and Containers with respect to the architecture. 

     Now we can say that VMs are an abstraction of physical hardware turning one server into many servers.  This hypervisor allows multiple VMs run on a single machine.  And each VM includes a full copy of an OS, an application, necessary binaries and libraries, taking up tens of GBs.  VMs can also slow to boot.  Can also take some time to boot.  Whereas coming to Containers, Containers are an abstraction at the application layer.  That packages code and dependencies together.  Multiple Containers can run on the same machine and share the OS kernels with other Containers.  Each running as isolated process in users’ space.  Containers takes less space than VMs.  Container images are tens of MBs in size and they can handle more applications and require few VMs on the Operating System.  So these are the differences with which we can start working with our Containers. 

 

WHAT ARE CONTAINERS?

     Let us understand what are Docker Containers.  A Container is a standard unit of software that packages of code and all its dependencies, so that the application can run quickly and reliably from one computing environment to another.  Means in simple, a Container a Docker Container is nothing but a package which will have application, its dependencies and the binaries of the application, that’s all.  A Container is a light weight standalone executable package in simple.  Let’s see what are these Containers in detail. 

     To understand Containers, let’s talk about the Container Architecture.  From this diagram we can see that there is a server, above is, there is a host Operating System.  And on the host Operating System, we have Docker Engine running.  Docker Engine is nothing but Docker Demon or Docker software running.  Above this we have Containers and we can have any number of Containers running above this Docker Engine.

 

 Docker Engine is responsible for running the Containers or creating the Containers.  And if we look it into each Container in detail, we can see every Container will have the application and the binaries and the libraries of the application. That’s all.  Nothing else.  Meaning Container will not have its own Operating System.  It will share the Operating System of the host.  Hence, because Containers don’t have their own Operating System, they are light weight, and they work really very faster.  When compare with VMs, they are really light weight because they don’t have OS, they need not allocate system resources for the specific Operating System for each Container. 

 

Hence, Containers are light weight and they really work very faster.  Containers isolate software from its environment and ensures that it works uniformly despite the differences for instance differences between Dev and Staging Environment and Containers are light weight and they are portal.  Containers will share the Machines Operating System like Kernel and all.  Let’s we are talking about Linux Containers, they will not have their own Kernel, they will share the kernel of the host Operating System.  And they do not require their own Operating System and hence they work really efficient and faster. 

DOCKER ARCHITECTURE

In this session we will talk about the Docker Architecture.  Docker Architecture works on client server model.  And these are the main components of Docker Architecture like

Docker Client

Docker Daemon and

Docker Registry

 what is Docker Client? 

Docker Client is something like which provides a UI to interact with Docker Daemon.  It provides a way to interact with Docker Daemon.  It’s something like a shell which provides a way to interact with the kernel.  Similarly, Docker Client provides a way to interact with the Docker Daemon.  So, to create an image or to create a Container, or to run a Container, we have to tell Docker Daemon through the Docker commands which are issued from this Docker Client.  

 

And hence the commands like Docker run, Docker pull, all these are called as Docker Client commands.  These commands will interact with the Docker Daemon, means tell Docker to do the respective tasks.  And hence Docker Daemon performs the actual task of running the images, creating the Containers and so on. 

 

And whenever we install Docker, we get this Docker Daemon and Docker Client both get installed by default.  And we interact with this Daemon by writing the commands like Docker run commands.  And Docker Client interacts with the Daemon through the API calls.  So that’s how actual work happens, actual process happens and then comes another component called Docker Registry. 

What is Docker?

 Registry is nothing but a storage place for your images.  For later usage we can store our images on Docker Registry.  Docker Registry is nothing but Docker Hub, which is managed by Docker, which is a public Registry.  We can also have private Registries and all.  Now let us install Docker and let’s see how it works, before going to that let me show you the Docker Architecture.  See here, these are three components like you have Docker Client, Docker host and Registry. 

We issue the commands like Docker Build, Docker Pull, Docker Run, Docker is the key word and Docker commands starts with Docker keyword and whenever, let’s suppose Docker Pull command.

 What does Docker Pull command does, it first interacts with Daemon.  Like any command we run will interact with the Daemon.  So, Docker pull means, it is downloading an image from Docker Hub.  So, whenever we run Docker pull command, it will go to the Registry, see here it will go to the Registry get the image, download it to the Docker Host.  Docker Host.  What is Docker Host?  Docker Host is nothing but a VM or a server where Docker Daemon is running, where Docker Engine is running.  So we need to have Docker installed to work with Containers, to work with images.  So, Docker Pull is the command, whenever Docker pull is issued from the Docker Client, it interacts with Daemon and Daemon will help to get the image downloaded from the Docker Registry, which is nothing but Docker Hub.  Similarly, Docker Run.   Whenever we issue the command Docker Run and some image name, this is the actual command, like Docker Run and the image name.  So, whenever this command is issued, it again interacts with the Daemon, Daemon will first search for the image locally in the Local Registry, if the image is there it will run the image.  If the images are not present locally, it will go to the Hub, download the image and run the image to get a Container.  So this is the architecture of the Docker in simple.  

 

     We will see this on the lab how it works.  Let us install Docker and let’s see Docker Client, Docker Daemon and let’s see how this command works.  Here this is Linux CENTOS  Operating System, here I took an instance on GCP, now let us install Docker here. 

 

“yum install docker”

 

means it installs Docker Daemon or Docker Engine.  Here we install Docker Daemon or Docker Engine, we get Docker Client installed by default.  Docker is installed. 

 

Now let us run the command

 

“Docker Version”

 

 Here you can see the version of your Docker installed and let us start Docker.  You can see Docker started.   Once docker is started,

 

if you run this command

 

 

“Docker Version”

 

 here you can see two sections like that Docker Client Version and the Docker Server details.  This is nothing but your Docker Client which we are talking about which provides an UI to interact with Docker Daemon and this is nothing but the Docker Daemon.  Now this terminal or this is nothing but your Docker Client, like from where you write your commands.

 

 Let us write some Docker command, the basic command

 

"docker run hello –world”

 

 what this command does, hello world is nothing but an image name and Docker Run will run this image  and whenever we run the image, we get an instance ,get a container created from this image.  Hence Containers are called as running instances of the images and what this command actually does?  Let’s get to the architecture.  Whenever we run the Docker run command from the Client from Docker Client, Docker Client is nothing but which provides the interface to interact with Daemon, means these are nothing but Docker Client commands.  So whenever I run this “Docker Run” command, this command will search for that means it will first interact with the Daemon, Daemon will first search for this image in our local registry, Means on the same system where we running this commands. If the image is there it will run directly, if the image is not there in the local registry it will go to the public registry Docker Hub and it will download the image from the docker registry and it will run the image.  Let us see, now let us run this command, here we can see very clearly first it is searching for the image locally.  Hello world image is not there in the local registry, so it was pulling from Docker Hub. “docker. Io” is nothing but the Docker Hub Registry the public registry.  So, it has downloaded from it and this message, this image is printed from this image, hello world image is running, it creates a Container and this message is being displayed.  So that is how it works. 

 

     So these are nothing but Docker Client commands, whenever we run this Docker Client commands, they interact with the Daemon through API calls and the Daemon will does the respective task.  If the image is present locally it will run directly, otherwise it will download from Docker Hub.  Now if we check the list of images, Docker images will show the list of hello world, now it is on our local registry.  Similarly let us see Docker Pull command.  Docker pull, we can download any image, let’s see, I am downloading ubuntu image.  Means it will download the latest ubuntu image from Docker Hub.  Here you can see, it was pulling all the file system layers, what are this file system layers will be discussing in the coming up sessions.  Now we should be seeing the ubuntu image as well.   

 

“Docker images”.

 

 You can see that ubuntu image.  So, whenever we run command,

 

“ Docker Pull <image name>”

Ex “Docker pull ububtu”

 

 It is again interacted with the Daemon, Daemon will go to the registry and will download the image to the local registry.  So these are the simple basic commands of Docker and that’s how the architecture of the Docker works.

Phone: 91-9966-5923-95

  • Facebook Clean
  • Twitter Clean

 

© 2020 by NEWAXIS.in