What is Docker? Why it is Better then Virtual Machines?

Posted by

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

What is Docker?

Docker is a platform for developing, shipping, and running applications in lightweight, isolated environments called containers. It streamlines software delivery by packaging applications with dependencies, ensuring consistent behavior across environments. Below is a detailed breakdown of Docker, its advantages over traditional methods, and related concepts.

Why Docker?

  • Isolation: Containers bundle applications with libraries/configurations, eliminating “works on my machine” issues.
  • Portability: Containers run uniformly on laptops, cloud platforms, or hybrid environments.
  • Efficiency: Containers share the host OS kernel, reducing resource overhead compared to virtual machines (VMs).

Docker vs. Virtual Machines

FeatureDocker ContainersVirtual Machines (VMs)
Resource UsageLightweight (MBs)Heavy (GBs for OS + apps)
Boot TimeMilliseconds to secondsCouple of Minutes
IsolationProcess-levelHardware-level (hypervisor)
ScalabilityRapid scalingSlower due to OS overhead
Use CaseMicroservices, CI/CDLegacy apps, full OS isolation28

Key Components

  • Docker Daemon (dockerd): Manages containers, images, and networks.
  • Docker Client: CLI tool to interact with the daemon (docker run, docker build).
  • Docker Desktop: GUI for managing containers on macOS/Windows.

Process ID (PID)

A Process ID (PID) is a unique numerical identifier assigned by the operating system to each running process. It enables the OS to manage resources, schedule tasks, and terminate processes3.

How PIDs Work

  1. Assignment: The kernel assigns a PID when a process starts (e.g., via fork() in Linux).
  2. Management: Tools like ps or kill use PIDs to monitor/control processes.
  3. Recycling: After a process terminates, its PID becomes available for reuse.

Example

  • In Linux, the init process (PID 1) is the ancestor of all other processes.

Kernel Explained

The kernel is the core component of an operating system, responsible for:

  • Process Management: Scheduling tasks and assigning PIDs.
  • Memory Management: Allocating RAM to processes.
  • Hardware Interaction: Communicating with devices via drivers.

Kernel Types

  • Monolithic: All OS services run in kernel space (e.g., Linux).
  • Microkernel: Only essential services run in kernel space (e.g., MINIX).

Why Docker Replaced Traditional Methods

  1. Speed: Containers start in seconds vs. VM boot times.
  2. Density: Run more apps per server due to shared OS resources.
  3. Consistency: Eliminate environment-specific bugs.

By leveraging containers, Docker addresses the inefficiencies of VMs and manual deployment, making it a cornerstone of modern DevOps and cloud-native development.


Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x