Day 16 Of My #90DaysOfDevOps Challenge: Docker for DevOps Engineers

Siddharth PatilSiddharth Patil
5 min read

Docker is a containerization tool that allows you to run applications in isolated environments called containers. These containers are portable, lightweight, and ensure consistency across different environments. But before we dive into Docker, it's important to understand the difference between virtualization and containerization.

Docker simplifies the entire application lifecycle from development to production, making it an essential tool for DevOps engineers. In this blog, we’ll explore Docker, how it works, and the difference between virtualization and containerization, along with some essential Docker commands every DevOps engineer should know.

Virtualization vs. Containerization

Both virtualization and containerization aim to achieve the same goal: running an application that requires an environment you don't have available. However, they do this in different ways.

Virtualization

In virtualization, we use a hypervisor (like VirtualBox) to create virtual machines (VMs) that run on physical hardware. Each VM has its own operating system, which consumes dedicated resources, such as CPU, RAM, and storage.

  • Example: Think of a banglow. Just as a banglow is a large individual house that needs its own foundation, resources, and utilities (like water and electricity), a virtual machine requires its own operating system and allocated resources to run.

  • Key Points:

    • Allocates dedicated resources for each VM.

    • Hypervisor is required to manage the virtual machines.

    • Higher cost due to the need for more resources and additional overhead.

    • VMs are large in size because each one contains its own OS.


Containerization

On the other hand, containerization uses tools like Docker to create containers. These containers share the host operating system's kernel but are isolated from each other. The Docker engine manages the containers, making them lightweight and fast.

  • Example: Think of apartments in a building. While each apartment has its own living space (container), they share the same infrastructure (building) like the plumbing and electricity (kernel). This shared approach makes the resources more efficient and the overall setup more cost-effective.

  • Key Points:

    • Containers share resources from the host system.

    • Docker engine is used to manage containers.

    • Lower cost because resources are shared and not duplicated.

    • Containers are smaller in size since they don’t need a separate OS.

    • No kernel in the container itself — the host OS kernel is used.


Docker Engine: The Heart of Docker

Docker runs on the Docker Engine, which consists of several components that work together to create, manage, and run containers:

  1. Docker Daemon (dockerd):
    This runs in the background and is responsible for managing containers, ensuring they are running and performing as expected.

  2. Docker CLI:
    The Command Line Interface (CLI) is used to interact with the Docker Daemon. With the CLI, you can issue commands to build, run, and manage containers.

  3. Containerd:
    Containerd is a CNCF (Cloud Native Computing Foundation) project that is used to manage containers on the backend. It helps in container creation, execution, and monitoring.


Docker: A Platform as a Service (PaaS)

Docker is considered a Platform as a Service (PaaS) because it abstracts away many complexities of managing applications. With Docker, you can easily containerize your application and deploy it across different environments without worrying about the underlying infrastructure.


Key Docker Commands and Tasks

Let’s dive into some essential Docker commands every DevOps engineer should know.

1. Run a New Container

The docker run command is used to start a new container.
Example:

docker run hello-world

This command runs a test container that outputs a confirmation message, showing that Docker is installed and working correctly.


2. Inspect a Container or Image

The docker inspect command provides detailed information about a container or image.
Example:

docker inspect hello-world

This helps you examine metadata and status information about the container or image.


3. Check Port Mappings

The docker port command shows the port mappings for a running container.
Example:

docker port <container_id>

This is useful to see which ports on your system are mapped to the container.


4. Monitor Resource Usage

The docker stats command displays real-time resource usage for containers.
Example:

docker stats

This command is valuable for performance monitoring.


5. View Running Processes

The docker top command shows the processes running inside a container.
Example:

docker top <container_id>

This is helpful for troubleshooting and monitoring.


6. Save a Docker Image

The docker save command lets you save an image to a .tar archive.
Example:

docker save -o my_image.tar hello-world

This is useful for backup or sharing images.


7. Load a Docker Image

The docker load command lets you load an image from a .tar archive.
Example:

docker load -i my_image.tar

This is helpful for restoring or using saved images.


Conclusion

Docker is a powerful tool that makes application deployment easy and consistent. By learning the basics of containerization and the key Docker commands, you can effectively manage containers and streamline your DevOps processes.

Remember, Docker is a game-changer when it comes to efficient resource management, cost savings, and simplifying application deployment across environments.

Stay tuned for more DevOps adventures! Let’s keep learning and growing together! 🌱🚀

Keep learning, keep growing! See you tomorrow for Day 17! 💪

Let’s keep learning and sharing our knowledge with the DevOps community!

#DevOpsJourney #LearningTogether #GrowthMindset #TechCommunity #TrainWithShubham #90DaysOfDevOps

Let’s keep learning and share our experiences with the DevOps community! 🚀
Feel free to comment below and share your Docker journey. Happy learning! 😊

0
Subscribe to my newsletter

Read articles from Siddharth Patil directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Siddharth Patil
Siddharth Patil

👋 Hi, I'm SIDDHARTH PATIL, a DevOps learner diving into Linux and cloud computing. 🚀 Currently mastering the basics and excited for the journey ahead! 💻☁️ #DevOps #Linux #CloudComputing"