Q1. What is Docker?
Docker is a control Management Platform/Tool.
Tool is used for saving cost, saving time and improve quality.
Using Docker we can create, start, run, pause, delete and stop the container.
It is a platform which allows us to build to manage the applications in lightweight, portable containers.
History of Docker:
Docker is actually name of the company - we have so many products in it like dotCloud, etc.
The first product of Docker is a Docker engine.
Why we change the Tool:
To save cost, save time and improve the quality. Same applies to when to migrated from Virtual to Docker.
Need of Docker:
It is Isolation: each applications runs its own Container without any conflicts.
It is Consistent: Can works on the same Dev, Test and Production environments.
It is Portable: Can run anywhere, on Cloud or Server or PC.
It is Efficient: Uses less Memory & storage than Virtual Machines.
Concepts of Docker:
Docker images: It is a template or blueprint.
Docker container: A running instance of an image.
Docker file: A script which defines how to build a Docker Image.
Docker hub: A public registry for sharing Docker images (Like GitHub).
Q2. What is Container?
Container is an actual product/outcome of the tool.
Containers are light-weight than Virtual Machines.
In Virtual Machine, has its own full Operating System. Whereas in Container shares the Operating System kernel.
In Virtual Machine, shares more RAM & CPU. Whereas in Container it is minimal resources.
In Virtual Machine, occupies more Memory. Whereas in Container it is less.
History of Container:
Containers aren't a new technology, they have been around for decades. Docker made them easy, portable and developer friendly.
Life cycle of Docker Container:
To create, start, run, pause, delete and stop are the process involves in Docker Container cycle.
Q3. What are Docker Components?
Docker Components:
A. Docker image,
B. Docker container,
C. Docker engine,
D. Docker file,
E. Docker hub or registry,
F. Docker network, and
G. Docker volume
A. Docker Image
Read-only blueprint which used to create containers.
Which creates the Container: (Ex: 1 Root File System, 1 User File System, Application File System)
Root file system can be Linux, Windows OS, etc.
User file system can be User1, User 2, etc.
Application file system can be Apache, Notepad, etc.
B. Docker Container
A running instance of Docker Image.
C. Docker Engine
Docker Engine is Software, PC, Client, and Server that can run wherever everywhere we can.
The client-server communication that executes the Docker.
It has 2 parts:
Docker Daemon (which runs in the background and manages images, containers, etc).
Docker CLI (which is the Command-line tool to interact with Docker.
D. Docker File
A script which contains the instructions to build a Docker image.
E. Docker Hub
A cloud-based registry used to store and share the Docker Images.
Docker hub is a registry, which has Docker image = 1 Root File System +1 User File System
F. Docker Volume
Which is Consistent, persistent storage mechanism for Containers.
G. Docker Network
Which enables the communication between containers and external systems.
Q4. What is Docker Workflow?
A. Docker to Container
A lightweight runtime environment and the solution is Containers.
Implies to creates or configures the container using Docker tools.
B. Client-Server Docker Architecture
User run a Docker command (Ex: Docker run).
Hits the Docker Client, which talks to the Docker Daemon (dockerd) a Server.
dockerd checks if the image is available locally.
If not found, pulls from Docker Hub.
C. Docker Daemon to Container Runtime (dockerd ----> containerd ---> kernel)
dockerd: Main docker server process.
containerd: Lightweight container runtime that manages container lifecycle.
Communicates with the kernel to create Namespaces and control groups.
D. Namespaces and Isolation
When container is created, Docker uses Namespace to isolate it.
USER ---> User access inside container
NET ---> Network stack (container gets its own virtual network)
PID ---> Process IDs inside the container
MNT --> Filesystem mount points (container sees only its own file system)
E. Container Construction
These namespaces and isolated environments are attached to as user process, forming a container.
One container = an isolated instance with its own processes, network, and filesystems.
Workflow Preview:
User ---> Docker CLI ---> Docker Daemon (dockerd)
---> Image lookup (local or pull from Docker Hub)
---> containerd runs container
--->Two types of Kernels (Based on Host OS - Linux, Windows)
- We should not compromise stability and security of Kernel and User space while they communicate
 
- Kernel must not be compromised to ensure container isolation
---> Kernel creates namespaces (USER, NET, PID, MNT) 
---> All together to user process = 1 Container (Fully isolated)
Q5. What is Container Lifecycle?
Container Lifecycle:
A. Create
B. Start
C. Pause
D. Unpause
E. Stop
F. Kill
G. Restart
F. Delete or Remove
A. Create or Run
Container is created from image but not running yet.
B. Start
Starts a new or stopped created container.
C. Pause
Temporarily suspends processes inside the container. But container exists.
D. Unpause
Resumes a paused container.
E. Stop
Stops a running container. Container remains on disk.
F. Kill
Forcefully stops the container immediately.
G. Restart
Stops and then starts the container again
I. Remove or Delete
Deletes the container completely. And it cannot be restarted again.