✅Table of Content
🐋What is Docker?
🐬Docker Architecture
🐋Advantages of Docker
🦭Disadvantages of Docker
🐟Docker Components
🐳Docker Commands
🎉Conclusion:
🐋What is Docker?
Docker is an open-source platform that automates the deployment of applications inside lightweight, portable containers. Containers can run on any system that supports Docker, providing consistency across multiple development and release cycles.
🐋Docker Architecture :
Docker is an open-source centralized platform designed to create, deploy and run application.
Docker uses 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 OS.
We can install docker on any OS but docker engine runs natively on Linux distribution.
Docker written in 'go' language.
Docker is a tool that performs OS level virtualization, also known as containerization.
Before docker, many users faces the problem that a particular code is running in the developer's system but not in the user's system.
Docker was first release in "March 2013". It is developed by "Solomon Hykes" and "Sebastian Pahl".
Docker is a set of platform as a service that uses OS level virtualization whereas VMware uses hardware level virtualization.
🐋Advantages Of Docker :
No pre-allocation of RAM.
CI (Continuous Integration) efficiency: Docker enable you to build a container image and use that same image across every step of the deployment process.
Less cost & light in weight.
It can run on physical H/w / Virtual H/w or on cloud.
You can re-use the image.
It took very less time to create container.
🐋Disadvantages of Docker :
Docker is not a good solution for application that requires rich GUI.
Difficult to manage large amount 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 OS and testing OS are same. If the OS is different, we should use VM.
No solution for Data recovery & backup.
🐋Components of Docker :
- Docker Daemon
Docker daemon run on that Host OS.
It is responsible for running containers to manages docker services.
Docker daemon can communicate with other daemon.
- Docker Client
Docker users can interact with docker daemon through a client.
Docker client uses command and Rest API to communicate with the docker daemon.
When a client runs any server command on the docker client terminal, the client terminal sends these docker commands to the docker daemon.
It is possible for docker client to communicate with more than one daemon.
Docker Host
Docker Host is used to provide an enviroment to execute and run applications. It contains the docker daemon, images, containers, networks and storages.
Docker HUB / Registry
Docker registry manages and stores the docker images. These are two types public and private.
Docker images
Docker images are the read only binary templates used to create docker container.
Single file with all dependencies and configuration required to run a program.
- Docker Container
We can say that the images is a template and the container is a copy of that template.
Container is like a Virtual Machine.
Image becomes container when they run on docker engine.
Docker file
Docker file is basically a text file. It contains some set of instructions.
Let's go through some basic Docker commands to get you started.
🐋Basic Docker Commands :
Update the package index
sudo apt-get update -y
Install the latest version of Docker
sudo apt-get install docker.io -y
Check docker version
docker --version
Check status of docker service
sudo service docker status OR systemctl status docker
press "q" for exit.
To see all images present in your local machine.
sudo docker images
Give permission to docker user to run docker commands without "sudo".
sudo usermod -aG docker $USER
Now check docker user added or not in group at last line.
cat /etc/group
Now restart your instance.
sudo reboot
It take few minutes to restart or you can connect your instance again.
Again see all images present in your local machine.
docker images OR docker images ls
To see running container.
docker ps
To see all container active or inactive.
docker ps -a
To find out images in docker hub.
docker search <image name>
To download image from docker hub to local machine.
docker pull <image name>:tag
To create and run container by giving name using docker hub image.
-it = interactive terminal
docker run -it --name <container name> <image name> /bin/bash
To exit from container.
exit or Ctrl+c
To start container.
docker start <container ID / Name>
To go inside container.
docker attach <container name>
To stop container.
docker stop <container name>
To delete stop container.
rm = remove
docker rm <container name>
To remove a local image.
docker rmi <imagename>:tag
To tag an image.
docker tag <sourceimage>:tag <newimage>:tag
Build an image from dockerfile.
docker build -t <imagename> path_of_Dockerfile
Push an image to docker hub.
docker push <image_name>:tag
Inspect details of an image.
docker image inspect <image_name>:tag
Save an image to tar archive.
docker save -o <image_name>.tar <image_name>:tag
Load an image from tar archive.
docker load -i <image_name>.tar
Prune unused images.
docker images prune
To view container logs
docker logs <container_name/ID>
🐋Conclusion :
Docker provides vital commands for effective container oversight. Users manage containers (docker run), inspect details (docker inspect), handle port mappings (docker port), monitor resources (docker stats), observe processes (docker top), and export/import images (docker save/docker load). These tasks enhance container orchestration, guaranteeing smooth application deployment and monitoring.
Happy Learning !😊