Docker Introduction: -
1) Docker used a Client-Server architecture
2) Docker is a community and It is Open-source container technology.
3) It has 3 components
a) Docker client
b) Docker Daemon
c) Docker Registry
4) We use Docker client to communicate with docker daemon, which does the heavy lifting of building, running, and distributing your docker containers
5) Docker client and Docker daemon communicate using REST API, over a UNIX socket or a network interface.
6) You can install the Docker client and Docker daemon on the same machine/a different machine.
Limitations of Hardware-based Virtualization: -
1) Virtualization is a Technology by which we can run multiple machines on hardware simultaneously.
2) Hardware-based Virtualization has limitations like server Provisioning which affects product delivery and multiple applications cannot run in a single VM due to Library conflict issues/Environment conflict/Software dependency.
Advantages of Docker Container: -
1) Docker container is an OS based on Virtualization
2) It creates an Isolate environment for Applications.
3) Using a container, we can run multiple applications/software inside a single OS without Library/Binary/Network conflict.
4) Docker container is not full OS, it consists of a minor footprint of OS/Software related dependencies (Library/Binary/Config file)
Docker Architecture: -
1) Docker client is a command line utility that we used to communicate with the Docker daemon
2) Docker daemon is a background service that is responsible for building, running and distributing the docker container
3) Docker Images is a lightweight image for the application. It has community-based/custom images.
5) Docker Host/Engine is a machine/OS that will run multiple containers
6) Docker container is a micromachine running over the docker host, We can run multiple containers using the same docker image
7) Docker registry is a place where we store docker images, which can be public/private.
----Once we enter the command “docker pull ubuntu” on the docker client, this request goes to the Docker daemon, and the docker daemon checks whether the ubuntu image is available on the local machine or not, if the image is available in the local machine then it will give response to docker client that image is available if not available then docker daemon sends the request to default docker registry (Docker hub) and from docker hub we download the image to the local machine, once the image is download then docker daemon sends the response to docker client that image is downloaded.
Now, we have to create one container using a Redis image, once we enter “docker run redis” this request goes to the docker daemon, and the docker daemon checks whether redis image is available on the local machine or not and if the image is available in the local machine then it will give response to docker client that image is available if not available then docker daemon sends the request to default docker registry (Docker hub) and from docker hub we download the Redis image to the local machine, once Redis image is download then docker daemon creates a new container from Redis image if we want to run another container with the same Redis image then, in this case, Docker daemon will create the container from Redis image which is available in local machine. It will not contact the docker hub this time.
Binaries of the container is located at /usr/bin/containerd
ubuntu, nginx & alpine images pulled from the docker hub
Deployment of a container con1 by taking image:nginx and data writing in that container, the changes will be saved in the upper directory of the docker host, you can check abc & web is in the upper directory.
The lower directory has so many layers as it is a readable layer as we pulled 3 images, all the container level changes are stored in the backend on /var/lib/docker/overlay2, if the lower layer directory file needs changes then as per COW (copy on write) concept file will get copied form lower to the upper directory which causes latency issue.
It shows one container running which is taking minimal size, the container does not need any extra size as the image size itself is container size.
check image history & container logs:-
Container stop/start:-
Stop & Remove all running containers:-
Remove all images from the docker host which will empty the lower directory under /var/lib/docker/overlay2/