Docker for DevOps Engineers part-I
Introduction to docker π¦π₯
Docker is a platform and tool that enables you to develop, deploy, and run applications inside containers.
Containers are lightweight, standalone, and executable software packages that include everything needed to run a piece of software, including the code, runtime, system tools, system libraries, and settings.
Docker is an open-source centralized platform designed to create, deploy and run applications.
Docker uses containers on the host o.s to run applications. It allows applications to use the same Linux kernel as the system on the host computer, rather than creating a whole virtual Os.
We can install Docker on any o.s but the Docker engine runs natively on Linux distribution.
Docker is written in the 'go' Language.
Docker is a tool that performs o.s level virtualization, also known as Containerization.
Before Docker, many users face the problem that a particular code is running in the developer's system but not the user's system.
Docker was the first Release in March 2013. Soloman Hykes and Sebastion Pahl develop it.
Docker is a set of platforms as a service that uses o.s level virtualization whereas VMware uses hardware-level virtualization.
Advantages of Docker ποΈ
No pre-allocation of RAM.
CI-efficiency- Docker enables you to build a Container image and use the same image across every step of the deployment Process.
Less cost
It is light in weight.
It can run on physical hardware/virtual hardware or the cloud.
We can re-use.
It took significantly less.
Disadvantages of Dockerπ«
Docker is not a good solution for application that requires rich GUI.
Difficult to manage a 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 o.s and testing o.s are the same if the o.s is different, we should use VM.
No solution for Data Recovery & Backup.
Architecture of Dockerπ§ββοΈπ΅οΈββοΈ
Docker Daemon
Docker daemon runs on the host o.s
It is responsible for running containers to manage docker services.
Docker Daemon can communicate with other daemons.
Docker Client
Docker users can interact with the docker daemon through a client (CLI).
The Docker client uses commands 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 the docker client to communicate with more than one daemon.
Docker Host
Docker Host is used to providing an environment to execute and run applications. It contains the docker daemon, images, container, networks, and storage.
Docker Hub/Registry
The Docker registry manages and stores the Docker images.
There are two types of registries in the docker.
Public Registry- Public registry is also called a docker hub.
Private Registry- It is used to share images within the enterprise.
Docker Images
Docker images are the read-only binary templates used to create docker containers.
In other words, a Single file with all dependencies and configuration required to run a Program.
Docker Container
The container holds the entire packages that are needed to run the applications.
In other words, we can say that the image is a template and the container is a copy of that template.
A Container is like a Virtual Machine.
Images become containers when they run on the docker engine.
installation docker
sudo apt-get update
sudo apt install docker.io
# To check docker version use docker --version
Challenges
A very common mistake that many beginners do is, After they install docker using the sudo access, they miss the step to Start the Docker daemon and grant access to the user they want to use to interact with docker and run docker commands.
Always ensure the docker daemon is up and running.
An easy way to verify your Docker installation is by running the below command
docker run hello-world
To grant access to your user to run the docker command, you should add the user to the Docker Linux group. A Docker group is created by default when Docker is installed.
After adding may be same error showing, You just need to reboot the system
sudo reboot
Docker tasks π§βπ»
- Use the
docker run
command to start a new container and interact with it through the command line. [Hint: docker run hello-world]
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
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.docker top <container ID >
command allows users to display the ps output for the main process of a given container ID or name.Use the
docker save
command to save an image to a tar archive.The
docker save
the command is used to save one or more Docker images to a tar archive. The output of this command is a tarball that can be used to transfer images between different Docker hosts or to create a backup of images.docker save -o OUTPUT_FILE IMAGE_NAME:TAG
Use the
docker load
command to load an image from a tar archive.Use the
docker load
command to load an image from a tar archive.
Thedocker load
the command is used to load Docker images from a tar archive created with thedocker save
command. It takes a tar archive containing one or more Docker images and imports them into the Docker image store.
Subscribe to my newsletter
Read articles from Suraj barik directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Suraj barik
Suraj barik
I'm Suraj Barik Aspiring DevOps Engineer with Hands-on experience in Automating,Shell Scripting, Supporting in AWS, management, CI/CD, and DevOps processes.