Thursday, 13 October 2022

Docker and kubernetes


Docker Containerization



Containerization is a lightweight virtualization technology alternative to hypervisor virtualization.
any application can be bundled in a container that can run without any worries about dependencies, Libraries, and binaries.
containers are designed to run on any physical server, virtual machine, and cloud instance.


Virtualization Vs Containerization



Virtualization technology allows us to have multiple operating systems to share a single hardware processor.

Containerization is application-specific virtualization, because it provides applications with dedicated environments in the form of containers to run on, which can be deployed and run anywhere without a dedicated virtual machine with the operating system for each application.

also, the container was designed to solve modern problems and application management issues. so it is not a replacement for virtualization, but it is complementary to it.


Advantages of Containerization




Containers are isolated, don't require an operating system, and share a host kernel. so containers run on the same server and use the same resource. they do not interact with each other because its isolated, if one application crashes, other containers with the same application will keep running without any issues.

It's a portable and lightweight operating system and it contains only the required binaries, dependencies, and libraries to run the application. so it can be moved anywhere easily and run without worrying about compatibility, or dependencies kind of issue.

faster and resource efficient it's very fast to boot because containers are lightweight and start in less than a second since they do not require an operating system boot.

improving scalability and lower costs by allowing more containers in the environment without the need for more servers, containerization increases scalability anywhere from 10 to 100 times that of traditional VM environments.


Introduction to Docker - What is Docker on Containers






Docker is an open-source platform tool designed to manage containers, which allows us to build the application in a container with required libraries, binaries, and dependencies to run the application, ship the contained, and run it anywhere.


                      Docker Architecture and Components



 

     Docker Installation


A few quick notes about Docker:docker-installation-on-ubuntu-article

Multiple containers run on the same hardware

Maintains isolated applications

Enables high productivity

Quick and easy to configure

Before learning about this technology, the first step is to install it. In this article, you’ll learn how to install Docker on Ubuntu. 


Ubuntu:

#sudo apt-get update
#sudo apt-get install docker.io

Verify the docker version 

#docker -v
#lsb_release -a

CentOS/RHEL:

#sudo yum -y install docker
#sudo systemctl start docker;sudo systemctl enable docker

verify the docker version
#docker -v
 
       Open the terminal on Ubuntu.

 

                       sudo apt-get install docker.io


docker -v

sudo systemctl status docker




1, Install all the dependency packages using the following command:

    $ sudo snap install docker

2, Before testing Docker, check the version installed using the following command:

   $ docker --version

3, Pull an image from the Docker hub using the following command:

   $ sudo docker run httpd

      Here, httpd is the docker image present on the Docker hub.

4, Check if the docker image has been pulled and is present in your system using the following  cmd              
    $sudo docker images

5, To display all the containers pulled, use the following command:

   $ sudo docker ps -a

6, To check for containers in a running state, use the following command:

   $ sudo docker ps

    You’ve just successfully installed Docker on Ubuntu!

Necessary comment to operate docker.

sudo docker search httpd

sudo docker pull httpd

sudo docker pull docker.io/exasol/nagios-monitoring

sudo docker images

sudo docker rmi "image id" ( to remove images)

sudo docker system df

sudo docker ps

sudo docker run -d -it --name web httpd

sudo docker exec -it web /bin/bash

sudo docker run -d -it --name web  -p 80:80 httpd

sudo docker stop web

sudo docker stats web

sudo docker events

sudo docker rm web

sudo docker rm -f web

sudo docker top web

sudo docker save imange id > https-backup.tar  (to take image as backup)

scp https-backup.tar ranjith@192.168.2.133:/home/ranjith/ (for SCP)

sudo docker load -i https-backup.tar ( it will load the image from local not in internet)

sudo docker commit "container Id" ( it will commit the image)

sudo docker commit d16a51d08814 customimage:2.1 (to add tag for commited images)

sudo docker run -d -it --name test1 customimage:2.1 /bin/sh ( to login custome image)

sudo docker exec -it  0b4a4fca58d6 /bin/bash ( to exec the custome image and verify)

sudo docker network inspect ff8866d57f1d

sudo docker network ls

ip a

sudo docker port web5

Docker run -i -t centos (to mount os)

docker cp aaca4f3bedb6:/opt/nagios/etc/ /root/Desktop

docker cp /root/Desktop/etc/nagios.cfg aaca4f3bedb6:/opt/nagios/etc/