Docker and Kubernetes Tutorial

Written by Sathish | Dec 8, 2020 7:11:27 AM

History of Containers 




                                       

 

 

Virtual Machines 

 Virtual machines generally include entire operating system along with the application. They also need a hypervisor running along with them to control the VM

Host Operating System : Host refer as the bare metal machine/server/node and the OS you install on server is called as Host OS. This OS can also be called as Hypervisor.so need a hypervisor running along with them to control the VMtion. 

Hypervisor : A hypervisor is also known as a Virtual Machine Manager (VMM) and its sole purpose is to allow multiple “machines” to share a single hardware platform   e.g VMware's ESXi Type 1 hypervisor , HyperV - WindowsGuest OS is the OS installed on virtual machine(VM) that is created on top of Host machine is called as Guest OS (GOS)

A physical server can have multiple virtual machines and each VM can run its own guest OS. One guest OS can run Linux while another could run Windows. 

Host Operating System VS Guest OSHost OS 

Host OS

  •  The host operating system is software on a computer that works with the  underlying hardware.

  •  A hypervisor, or host operating system, provides virtual CPU, memory and other resources to many guest operating systems. Each guest OS works as if it is running on actual physical hardware, and it is, ideally, unaware of other guests running on the same physical server.

Guest OS

  • The guest operating system is software installed onto and running on the virtual machine
  • The guest OS can be different from the host OS in virtualization. It mainly provides another OS for applications.
  • While the guest OS shares resources with the host OS, the two operate independently of one another. These various operating systems can run at the
    same time, but the host operating system must bestarted initially.
  • One of the major benefits of using a guest OS is the ability to run programs and applications that don’t work with the host OS.

Advantages of Containers 

Standardization

 Most containers are based on open standards and can run on all major Linux distributions, Microsoft, etc

Computing environment portability

 Containers encapsulate all the relevant details like application dependencies and operating systems, which are essential to run the application. This helps ease the portability of the container image from one environment to another. For example, the same image can be used to run in Windows/Linux or dev/test/stage environments.

  • Because environment is self-contained, runs the same on all infrastructure –laptop, desktop, cloud, etc.
  • Portable across any OS or cloud that supports containers.
  • Resource isolation and (hopefully) effective utilization.
  • Manage application instead of infrastructure

Disadvantages of Containers 

  • Increased complexity:

With n number of containers running an application, there is an increase in the complexity factor as well. Management of so many containers can be a challenging task in a production environment. Tools like Kubernetes and Mesos can be utilized to manage n number of containers.

  • Native Linux support:

Most container technologies, such as Docker, arebased on Linux containers (LXC). Therefore, running these containers on a Microsoft environment is a bit clumsy and their daily use can bring up complications, compared to running these instances on Linux natively.

How Containers from Docker differ from VM

 

   

 What are Containers

 A container is a standard unit of software that functions likea fully provisioned machine installed with all thesoftware needed to run an application.

 It’s a way of     packaging softwareso that applications and their dependencies have a self-contained environment to run in, are insulated from the host OSand other applications -and are easily portedto other environments.   

 A container is NOT a VM.  Acontainer leverages several features of the Linux OS to “carve out” a  self-contained space to runin. 

Containers are running instances of images.

Images define what goes into a container.

Containers are built from images.

 

How Containers Deployment differ from traditional deployment

 

   .   

                       TRADITIONAL DEPLOYMENT                   VIRTUAL DEPLOYMENT

                                 

                                                    CONTAINER DEPLOYMENT   

How Containers from Docker differ from VM    

                    Virtual Machine                    

                       Container

Starts in minutes(boot). The provisioning of resources takes time. Each virtual disk image is large and bulky and getting a VM ready for use can take up to a minute!

Starts in Milliseconds(boot)

Waste Resources( Each Guest OS will take approximately 800 mb X Number of applications running

800 Mb *3 =2.4 GB +CPU and Memory resources

Save Resources

virtualization required to run different applications

virtualize the operating system (your standard libraries, packages, etc) itself, not the hardware
Isolate Systems and system resources

Isolate applications

VM mainly used for isolating different customers

Container mainly used for isolating applications.instead of providing virtual hardware to a VM, you provide a virtual OS to your application

VM is fully self contained .

 

Docker containers have shared infrastructure 

VM do not share infrastructure

Docker containers  share resources with your host os through Docker deamon

 

What Is Docker 

 Docker containers as really lightweight Virtual Machines

 Docker as a software packaging and delivery platform

   

What is a container image 

  • A container image is a read-only template used to create a container.
  • Container images are like a snapshot of a container.
  • Images are generally considered to be “immutable”. That is, once they are created, the image should not be changed. If a change is needed, a new image should be created.
  • Container images are built up from layers.
  • The docker “build” command is used to create images.

What is a Docker file 

 

Way to create a Docker image ( a plan)

 A text file that contains (in order) all of the instructions tobuild an image

 Has a specific format and structure

 Each instruction in a Docker filecan create a read-only layer

                         

 

Docker file 

 Docker build images by reading instructions from a Docker file. A Docker file is a text document that contains all the commands a user could call on the command line to assemble an image. 

 docker image build command uses this file and executes all the commands in succession to create an image.   

       

Docker Architecture

 

     

Docker file to Image to Container 

 

   

 

Docker Workflow  

          

       

 

Docker Workflow Lifecycle 

 

   

Docker Commands 

     

Launch AWS EC2 instance with Amazon Linux Image 

 

 

 

Launch AWS EC2 instance with Amazon Linux Image

 

                 

Windows for Docker 

 

   

 

Windows for Docker 

 

     

 

     

 

Open Windows PowerShell

 

     

 

Install Git bash for windows 

 

     

 

     

 

Get the source code from github 

 

     

 

Create a new folder and Copy the dotnet app from github 

 

     

List the images 

 

     

 

Run the application image 

 

   

 

Test the aspnet application 

 

   

 

Open PowerShell and go to the aspnet project source directory

 

       

 

Bridge Network Architecture 

 

       

 

Custom Bridge Network Architecture 

 

     

 

Overlay Networking Architecture