Day 16 -90DaysofDevOps

Docker for DevOps Engineers.

Containers vs. virtual machines:-

Containers, are lightweight and share the host machine's OS kernel. They package applications along with their dependencies into portable units called images. Containers run on containerization platforms like Docker or Kubernetes and offer faster startup times, efficient resource utilization, and easier scalability. They provide a consistent environment for applications across different deployment environments.

Virtual machines emulate hardware using a hypervisor, enabling multiple operating systems to run on a single physical machine. Each VM operates as a self-contained unit with its own OS, binaries, libraries, and applications. VMs provide strong isolation between applications but can be resource-intensive due to running a full OS for each VM.

Docker:-

Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.

Architecture

Docker-Client

The Docker client uses commands to interact with the Docker Daemon (Server). When a client runs any docker command on the docker client terminal, the client terminal sends these docker commands to the Docker daemon. Docker Client uses Command Line Interface (CLI) to run the following commands:-

  • docker pull

  • docker run

  • docker build

Docker Host
A Docker host refers to a machine or server that runs the Docker engine and is responsible for managing containers. It provides the necessary resources and infrastructure to create, deploy, and run Docker containers. The Docker host interacts with the Docker engine to start, stop, and manage containers, as well as handle resource allocation and networking for containerized applications.

Docker Registry

Docker Registry manages and stores the Docker images. It is of two types:-

Public Registry:- Public Registry is also called a Docker hub.

Private Registry:- It is used to share images within the enterprise.

Install docker to your system:

Docker can be installed in systems like Windows and Linux.

So I am using a Linux(Ubuntu) system to install the docker

Command to install docker

sudo apt-get update
sudo apt-get install docker.io -y
sudo usermod -aG docker $USER
sudo reboot

After running the about step wait for 3-5 minutes. And again login and check in your system if docker is installed or not.

Use the docker run command to start a new container and interact with it through the command line(I am using nginx for example).

docker pull <image name>
docker run -d --name <container name> -p 80:80 <image name>

Use the docker inspect command to view detailed information about a container or image.

  docker inspect < container-name >

Use the docker stats command to view resource usage statistics for one or more containers.

 docker stats <container id >

Use the docker top command to view the processes running inside a container.

docker to <container-id>

Use the docker save command to save an image to a tar archive.

docker save -o name.tar <image>

Use the docker load command to load an image from a tar archive.

docker load -i <image.tar>

Thanks for Reading;

Happy Learning