What is Docker?
Docker provides a platform for running applications in a containerized approach, where in each container have a file system, pid map and own network.
Docker directly interacts with kernel to create mount, pid map, network and a user for each application.
Below are the docker components.
- Docker Engine
Docker Engine is responsible for sending commands to kernel to create infrastructure for running an application
- Docker Image
Docker Image contains executable code and instructions like a template. This exists in registry which needs to be pulled and run.
What is Container?
Docker container provides runtime environment to run our application independently.
Each docker container has a separate file system, pid map, network and a user.
When an image pulled from registry and is run then that program will be run in a container
Benefit of Docker?
It is open source and no license is required.
provides isolated environment to run applications, so same kind of applications can be run independently without any conflict.
Saves Cost by running application in data centers, so the procurement of resource is limited.
Takes less time to setup and runs the application with minimal downtime.
Developers and QA can focus on their development and testing tasks instead of wasting their time for setup and running the applications in VM
User –> Docker client –>RESTFUL–> Docker Server(Deamon) –> ContainerD –> Kernal
This whole setup is inside Docker Engine.
create -> start -> stop -> start -> restart -> pause -> unpause -> kill -> remove
How Docker Works?
When a user runs any docker command then it will be first sent to Docker client.
Docker client checks and verify the command and send it to the Docker Daemon through REST.
Docker server receives the command and checks whether the image exists locally
if exists then the Docker daemon sends request to kernel to create separate file system, pid map, network and user then runs the image in a containerized manner
If not exists then the docker image is pulled from docker registry and performs the above step.