Table of contents
- What is virtualization?
- What is containerization?
- Docker:-
- VMs vs Docker Containers:-
- Architecture of Docker
- Components of Docker
- Installation of Docker
- Tasks:-
- Use the docker run command to start a new container and interact with it through the command line.
- Use the docker inspect command to view detailed information about a container or image.
- Use the docker port command to list the port mappings for a container.
- Use the docker stats command to view resource usage statistics for one or more containers.
- Use the docker top command to view the processes running inside a container.
- Use the docker save command to save an image to a tar archive.
- Use the docker load command to load an image from a tar archive.
What is virtualization?
Virtualization is a process that allows for more efficient utilization of physical computer hardware and is the foundation of cloud computing.
Virtualization uses software to create an abstraction layer over computer hardware that allows the hardware elements of a single computer—processors, memory, storage and more—to be divided into multiple virtual computers, commonly called virtual machines (VMs). Each VM runs its own operating system (OS) and behaves like an independent computer, even though it is running on just a portion of the actual underlying computer hardware.
What is containerization?
Containerization is the packaging of software code with just the operating system (OS) libraries and dependencies required to run the code to create a single lightweight executable—called a container—that runs consistently on any infrastructure. More portable and resource-efficient than virtual machines (VMs), containers have become the de facto compute units of modern cloud-native applications.
Docker:-
Open-source Centralised Platform designed to Create, deploy and run applications
It Uses a Container on the host OS to run applications It allows applications to use the same linux Kernel as a System on the host Computer rather than Creating a whole Virtual O S
We Can install Docker on any OS but D.E. runs natively on Linux Distribution
Docker written in ‘go language '
OS Level Virtualization also Known as Containerization
Docker is a Set of PAAS
Docker Advantages:-
Rapid Deployment
No pre-allocation of RAM
CI Efficiency , Build App only once
Less Cost and light weight
It can run on the Physical H/W ,VM
You can reuse the image
Less time to create container (VM)
Version Controlling
Portability
Isolation
Docker Disadvantages:-
Docker is not a good solution for application that requires a rich GUI.
Difficult to manage a large number of containers.
Docker does not provide cross-platform compatibility means if an application is designed to run in a docker container on windows, then it can’t run on Linux or vice-versa.
Docker is suitable when the development O.S and testing O.S are the same, if the O.S is different, we should use Virtual Machine.
No solution for Data Recovery & Backup.
VMs vs Docker Containers:-
Architecture of Docker
Components of Docker
Docker Daemon:- Docker daemon runs on the Host O.S and It is responsible for running containers and managing docker services. Docker daemons can communicate with other daemons.
Docker Client:- Docker users can interact with the docker daemon through a client and the Docker client uses commands and Rest API to communicate with the docker daemon. Docker clients can communicate with more than one daemon.
Docker Host:- Docker Host is used to provide an environment to execute and run applications. It contains the docker daemon, images, containers, networks, and storage.
Docker Hub/Registry:- Docker registry manages and stores the docker images. and there are 2 types of Registries are there 1> Public Registry and 2> Private Registry
Docker Images:- Docker images are the read-only binary templates used to create docker containers. or, a single file with all dependencies and configurations required to run a program.
Docker Container:- The container holds the entire package that is needed to run the application. or, In other words, we can say that the image is a template and the container is a copy of that template. container is like virtualization when they run on the Docker engine. Images become containers when they run on the docker engine.
Installation of Docker
Step 1:- Before installing Docker we need to make sure to update by running the below command
sudo apt-get update
Step 2:- After the update need to install Docker by running the below command
sudo apt-get install docker.io -y
Step 3:- After installing docker need to make sure that docker is installed or not So to check the docker version need to run the below command
docker --version
or
docker -v
Step 4:- If we need to check the docker running then we need to run the below command
service docker status
Tasks:-
Use the
docker run
command to start a new container and interact with it through the command line.
docker run
is used to create and start a new container
docker run -itd --name apache2 ubuntu/apache2
Use the
docker inspect
command to view detailed information about a container or image.
docker inspect command used to check in details for example we can use inspect command to check in the image deatils
docker inspect <image id>
Use the
docker port
command to list the port mappings for a container.
Use the
docker stats
command to view resource usage statistics for one or more containers.
docker stats
is a command in the Docker CLI (Command Line Interface) that allows you to view real-time resource usage statistics for one or more running Docker containers. It shows information such as CPU usage, memory usage, network input/output, and container ID, among other things.
Use the
docker top
command to view the processes running inside a container.
The docker top
command provides information about the CPU, memory, and swap usage if you run it inside a Docker container
Use the
docker save
command to save an image to a tar archive.
The docker save
command is used to save a Docker image to a tar file. This command helps move a Docker image from one registry to another or simply examine the contents of the image using the Linux tar command.
Use the
docker load
command to load an image from a tar archive.
docker load
command use to Load an image or repository from a tar archive. It restores both images and tags.
Thank you for reading!! I hope you find this article helpful!!
if any queries or corrections to be done to this blog please let me know.
Happy Learning!!
Saikat Mukherjee