<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Harshit Kumar</title>
    <description>The latest articles on DEV Community by Harshit Kumar (@harshit_kumar_bae0141f6a4).</description>
    <link>https://dev.to/harshit_kumar_bae0141f6a4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3524735%2Ff8233199-5f60-448e-bd8c-c127bac06717.png</url>
      <title>DEV Community: Harshit Kumar</title>
      <link>https://dev.to/harshit_kumar_bae0141f6a4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshit_kumar_bae0141f6a4"/>
    <language>en</language>
    <item>
      <title>Copy-on-Write Demystified: How OS and Docker Save Time and Space</title>
      <dc:creator>Harshit Kumar</dc:creator>
      <pubDate>Mon, 29 Sep 2025 10:44:37 +0000</pubDate>
      <link>https://dev.to/harshit_kumar_bae0141f6a4/copy-on-write-demystified-how-os-and-docker-save-time-and-space-5ld</link>
      <guid>https://dev.to/harshit_kumar_bae0141f6a4/copy-on-write-demystified-how-os-and-docker-save-time-and-space-5ld</guid>
      <description>&lt;h1&gt;
  
  
  Copy-on-Write (CoW) Explained: OS and Docker
&lt;/h1&gt;

&lt;p&gt;If you’ve ever heard the term &lt;strong&gt;Copy-on-Write (CoW)&lt;/strong&gt; and thought it sounds like some deep technical wizardry, don’t worry. It’s actually a simple and smart trick used in both &lt;strong&gt;Operating Systems&lt;/strong&gt; and &lt;strong&gt;Docker&lt;/strong&gt; to save time and resources. Let’s break it down in plain English.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Copy-on-Write?
&lt;/h2&gt;

&lt;p&gt;Normally, when you copy something in a computer (like memory or a file), the system makes a full copy right away.&lt;br&gt;&lt;br&gt;
But most of the time, that copy isn’t even changed.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Copy-on-Write (CoW)&lt;/strong&gt; says:&lt;br&gt;&lt;br&gt;
&lt;em&gt;“Don’t copy until someone actually changes it.”&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both the original and the copy &lt;strong&gt;share the same data&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;A new copy is made &lt;strong&gt;only when a modification happens&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This way, the system avoids wasting memory, disk, and time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Copy-on-Write in Operating Systems
&lt;/h2&gt;

&lt;p&gt;In OS, CoW shows up when we use the &lt;code&gt;fork()&lt;/code&gt; system call.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When a process calls &lt;code&gt;fork()&lt;/code&gt;, the OS creates a child process.
&lt;/li&gt;
&lt;li&gt;Instead of duplicating the entire memory space of the parent:

&lt;ul&gt;
&lt;li&gt;The parent and child &lt;strong&gt;share the same memory pages&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;If either process tries to &lt;strong&gt;write&lt;/strong&gt; to a page, &lt;strong&gt;then&lt;/strong&gt; the OS makes a private copy for that process.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Benefits:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Faster process creation (no full copy at fork time)
&lt;/li&gt;
&lt;li&gt;Lower memory usage (unchanged pages are shared)
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Copy-on-Write in Docker
&lt;/h2&gt;

&lt;p&gt;Docker uses CoW at the &lt;strong&gt;filesystem level&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker images are made of &lt;strong&gt;layers&lt;/strong&gt; (e.g., Ubuntu base → libraries → app code).
&lt;/li&gt;
&lt;li&gt;When you start a container:

&lt;ul&gt;
&lt;li&gt;It gets a &lt;strong&gt;read-only view&lt;/strong&gt; of the image layers.
&lt;/li&gt;
&lt;li&gt;A small &lt;strong&gt;writable layer&lt;/strong&gt; is added on top.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;If the container changes a file:

&lt;ul&gt;
&lt;li&gt;Docker doesn’t touch the original image.
&lt;/li&gt;
&lt;li&gt;Instead, it &lt;strong&gt;copies that file&lt;/strong&gt; into the writable layer and applies changes there.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Benefits:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Multiple containers share the same base layers → saves disk space
&lt;/li&gt;
&lt;li&gt;Containers start quickly (no heavy copying)
&lt;/li&gt;
&lt;li&gt;Isolation (changes in one container don’t affect others)
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  A Simple Analogy
&lt;/h2&gt;

&lt;p&gt;Think of it like &lt;strong&gt;sharing a Google Doc&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Everyone sees the same document at first.
&lt;/li&gt;
&lt;li&gt;If you just read it, nothing is copied.
&lt;/li&gt;
&lt;li&gt;If you edit it, Google gives you your own private version so you don’t mess with the original.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s exactly how CoW works.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Copy-on-Write (CoW) is a smart trick that makes systems more efficient:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;Operating Systems&lt;/strong&gt;, it speeds up process creation and reduces memory usage.
&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Docker&lt;/strong&gt;, it makes containers lightweight, fast, and isolated.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So next time you spin up a Docker container or run a &lt;code&gt;fork()&lt;/code&gt;, remember:&lt;br&gt;&lt;br&gt;
you’re benefitting from the magic of &lt;strong&gt;Copy-on-Write&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;by &lt;strong&gt;Harshit Kumar&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;DiCoTr&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
      <category>docker</category>
    </item>
    <item>
      <title>Containerization vs Virtualization: What’s the Difference and Why It Matters</title>
      <dc:creator>Harshit Kumar</dc:creator>
      <pubDate>Tue, 23 Sep 2025 13:44:37 +0000</pubDate>
      <link>https://dev.to/harshit_kumar_bae0141f6a4/containerization-vs-virtualization-whats-the-difference-and-why-it-matters-1770</link>
      <guid>https://dev.to/harshit_kumar_bae0141f6a4/containerization-vs-virtualization-whats-the-difference-and-why-it-matters-1770</guid>
      <description>&lt;h1&gt;
  
  
  Containerization vs Virtualization: What’s the Difference and Why It Matters
&lt;/h1&gt;

&lt;p&gt;In the world of modern computing, efficiency and scalability are everything. Organizations are constantly seeking ways to optimize their infrastructure, reduce costs, and speed up development. Two popular approaches that often come into discussion are &lt;strong&gt;containerization&lt;/strong&gt; and &lt;strong&gt;virtualization&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;At first glance, both seem similar—they let you run multiple applications on the same physical machine—but they differ in how they achieve this. Let’s dive deeper.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Virtualization?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Virtualization&lt;/strong&gt; is the process of creating multiple simulated environments (virtual machines) on a single physical server using a &lt;strong&gt;hypervisor&lt;/strong&gt;. Each virtual machine (VM) has:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Its own &lt;strong&gt;operating system (OS)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Virtual hardware (CPU, RAM, storage)
&lt;/li&gt;
&lt;li&gt;Applications running inside
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Running Windows, Linux, and Ubuntu VMs simultaneously on the same server.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros of Virtualization:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strong isolation between VMs (better security).
&lt;/li&gt;
&lt;li&gt;Ability to run multiple OS types on one machine.
&lt;/li&gt;
&lt;li&gt;Ideal for legacy applications that require specific OS.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** Cons of Virtualization:**  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Heavyweight: each VM needs its own OS.
&lt;/li&gt;
&lt;li&gt;Slower startup times compared to containers.
&lt;/li&gt;
&lt;li&gt;More resource consumption.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is Containerization?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Containerization&lt;/strong&gt; is a lightweight alternative where applications run inside &lt;strong&gt;containers&lt;/strong&gt;, sharing the host operating system kernel but maintaining isolation. Instead of a full OS, containers package:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application code
&lt;/li&gt;
&lt;li&gt;Dependencies (libraries, runtimes, configs)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Using Docker to deploy a Python app with all required dependencies in a container.  &lt;/p&gt;

&lt;p&gt;** Pros of Containerization:**  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lightweight: no need for separate OS in each container.
&lt;/li&gt;
&lt;li&gt;Faster startup and scaling.
&lt;/li&gt;
&lt;li&gt;Easier portability across environments (works the same on dev, test, and production).
&lt;/li&gt;
&lt;li&gt;Excellent for microservices architecture.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** Cons of Containerization:**  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weaker isolation compared to VMs (kernel sharing).
&lt;/li&gt;
&lt;li&gt;Not ideal for running different OS types on the same machine.
&lt;/li&gt;
&lt;li&gt;Security risks if not managed properly.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key Differences Between Containerization and Virtualization
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Virtualization (VMs)&lt;/th&gt;
&lt;th&gt;Containerization (Containers)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Isolation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Strong, full OS-level isolation&lt;/td&gt;
&lt;td&gt;Process-level isolation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;OS Requirement&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Each VM runs its own OS&lt;/td&gt;
&lt;td&gt;Shares host OS kernel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Startup Time&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Minutes (booting OS)&lt;/td&gt;
&lt;td&gt;Seconds (launch container)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Resource Usage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Heavy (multiple OS overhead)&lt;/td&gt;
&lt;td&gt;Lightweight (minimal overhead)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Portability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Less portable&lt;/td&gt;
&lt;td&gt;Highly portable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best Use Case&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Legacy apps, different OS needs&lt;/td&gt;
&lt;td&gt;Cloud-native, microservices&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  When to Use What?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Virtualization (VMs):&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running multiple OS types (Windows, Linux, etc.)
&lt;/li&gt;
&lt;li&gt;Hosting legacy applications that require full OS environments
&lt;/li&gt;
&lt;li&gt;Strong isolation and security requirements
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Use Containerization:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modern app development and deployment
&lt;/li&gt;
&lt;li&gt;Microservices and cloud-native applications
&lt;/li&gt;
&lt;li&gt;Rapid scaling and efficient resource use
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Future: Containers on Virtual Machines
&lt;/h2&gt;

&lt;p&gt;Interestingly, many organizations use a &lt;strong&gt;hybrid approach&lt;/strong&gt;—running containers inside virtual machines. This combines the isolation of VMs with the agility of containers, making it a popular setup in cloud environments like AWS, Azure, and Google Cloud.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;While &lt;strong&gt;virtualization&lt;/strong&gt; paved the way for efficient resource utilization, &lt;strong&gt;containerization&lt;/strong&gt; is driving the future of agile, cloud-native development. It’s not about choosing one over the other—they often complement each other depending on business needs.  &lt;/p&gt;

&lt;p&gt;If you need strong isolation and multiple OS types → &lt;strong&gt;Go with Virtualization&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
If you want lightweight, portable, and scalable applications → &lt;strong&gt;Choose Containerization&lt;/strong&gt;.  &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
