<?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: Argha-Nilanjon-Nondi</title>
    <description>The latest articles on DEV Community by Argha-Nilanjon-Nondi (@arghanilanjonnondi).</description>
    <link>https://dev.to/arghanilanjonnondi</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F492234%2Fed0d4e1b-a27a-4e58-a73d-9388149653e7.png</url>
      <title>DEV Community: Argha-Nilanjon-Nondi</title>
      <link>https://dev.to/arghanilanjonnondi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arghanilanjonnondi"/>
    <language>en</language>
    <item>
      <title>A real life case of Docker</title>
      <dc:creator>Argha-Nilanjon-Nondi</dc:creator>
      <pubDate>Fri, 20 Nov 2026 09:34:55 +0000</pubDate>
      <link>https://dev.to/arghanilanjonnondi/a-real-life-case-of-docker-3o63</link>
      <guid>https://dev.to/arghanilanjonnondi/a-real-life-case-of-docker-3o63</guid>
      <description>&lt;p&gt;Maya stared at the message from her teammate, Sam: &lt;em&gt;"Crashed on startup. Wrong Python version on my laptop."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On Maya’s computer, inside a neat folder called &lt;strong&gt;&lt;code&gt;Called_me&lt;/code&gt;&lt;/strong&gt;, sat a single file: &lt;code&gt;app.py&lt;/code&gt;. It was a tiny script, just a few lines of Python that printed a greeting and processed a quick calculation. It ran flawlessly on her machine, because her laptop happened to have the right version of Python and the right system libraries already installed. Sam’s didn’t.&lt;/p&gt;

&lt;p&gt;Instead of spending an hour debugging Sam’s laptop, Maya decided to use Docker. Rather than sending Sam just her code, she was going to send him an entire, self-contained environment.&lt;/p&gt;

&lt;p&gt;Staying right inside her computer’s &lt;strong&gt;&lt;code&gt;Called_me&lt;/code&gt;&lt;/strong&gt; folder, she created a new text file named &lt;code&gt;Dockerfile&lt;/code&gt;—no extension, just a blueprint. Inside it, she wrote four simple instructions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt; python:3.12-slim
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; app.py .
&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"python"&lt;/span&gt;, &lt;span class="s2"&gt;"app.py"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;She opened her terminal inside &lt;code&gt;Called_me&lt;/code&gt; and typed &lt;code&gt;docker build -t called-me:1.0 .&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In a few seconds, Docker read her &lt;code&gt;Dockerfile&lt;/code&gt; and forged something completely new: a &lt;strong&gt;Docker image&lt;/strong&gt;. Maya liked to think of an image as a &lt;strong&gt;sealed, independent block&lt;/strong&gt;. It wasn't just her Python script; it was a self-sufficient package containing a full miniature Linux operating system filesystem, the Python 3.12 runtime, all the necessary system libraries, and her code, all bundled together. Whether that block landed on her Windows laptop, Sam’s Mac, or a Linux server in the cloud, it carried its own OS environment inside it and didn't care what was installed on the host machine.&lt;/p&gt;

&lt;p&gt;What fascinated Maya most was &lt;em&gt;how&lt;/em&gt; Docker actually built that independent block. It didn't mash everything into one giant, messy file. Instead, it built the image as a stack of &lt;strong&gt;layers&lt;/strong&gt;—like stacking sheets of glass on top of each other, one for every line in her &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9peqzp0qv9y9ujf2h2le.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9peqzp0qv9y9ujf2h2le.png" alt=" " width="799" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, Docker read &lt;code&gt;FROM python:3.12-slim&lt;/code&gt; and created &lt;strong&gt;Layer 1&lt;/strong&gt;, laying down the heavy foundation: the base operating system and Python itself. Next, it read &lt;code&gt;WORKDIR /app&lt;/code&gt;, which created &lt;strong&gt;Layer 2&lt;/strong&gt; stacked right on top. Notice the shift in worlds here—this layer didn't touch Maya’s computer at all; it created a brand-new folder named &lt;code&gt;/app&lt;/code&gt; &lt;strong&gt;inside the image&lt;/strong&gt; and set it as the active directory. Then came &lt;code&gt;COPY app.py .&lt;/code&gt;, which generated &lt;strong&gt;Layer 3&lt;/strong&gt;. For this layer, Docker reached out to the &lt;strong&gt;&lt;code&gt;Called_me&lt;/code&gt; folder on Maya’s computer&lt;/strong&gt;, grabbed &lt;code&gt;app.py&lt;/code&gt;, and placed a copy of it into the &lt;strong&gt;&lt;code&gt;/app&lt;/code&gt; folder inside the image&lt;/strong&gt;. Finally, &lt;code&gt;CMD ["python", "app.py"]&lt;/code&gt; created &lt;strong&gt;Layer 4&lt;/strong&gt;—a tiny metadata layer stamped onto the very top, telling the image what to execute when someone eventually runs it.Each line in the &lt;code&gt;Dockerfile&lt;/code&gt; directly added a new, distinct layer onto the stack until the full image was complete.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftxz9zaaas4xiqzhsxr29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftxz9zaaas4xiqzhsxr29.png" alt="Docker , Docker Image , Docker Layers" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As each layer was created, Docker locked it down and calculated a unique &lt;strong&gt;checksum&lt;/strong&gt;—a long cryptographic fingerprint (a SHA-256 hash) generated from the instruction, the exact contents of the files involved, and the checksum of the layer directly beneath it. Once stamped with that checksum, the layer became permanently &lt;strong&gt;read-only&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An hour later, Maya spotted a typo in her code. She opened &lt;code&gt;app.py&lt;/code&gt; inside the &lt;strong&gt;&lt;code&gt;Called_me&lt;/code&gt; folder on her computer&lt;/strong&gt;, changed a single line, and hit save.&lt;/p&gt;

&lt;p&gt;Now, the &lt;code&gt;app.py&lt;/code&gt; on her computer was different from the &lt;code&gt;app.py&lt;/code&gt; frozen inside the &lt;code&gt;/app&lt;/code&gt; folder of her image. To update the image, she ran &lt;code&gt;docker build -t called-me:1.0 .&lt;/code&gt; again.&lt;/p&gt;

&lt;p&gt;Here was where the &lt;strong&gt;read-only&lt;/strong&gt; rule of Docker images showed its true power—and its strictness. Because an image is immutable, Docker &lt;em&gt;cannot&lt;/em&gt; reach into an existing layer, erase one line of &lt;code&gt;app.py&lt;/code&gt;, and patch it. Instead, Docker walked down her &lt;code&gt;Dockerfile&lt;/code&gt; from the top, checking checksums at every step.&lt;/p&gt;

&lt;p&gt;Line one, &lt;code&gt;FROM python:3.12-slim&lt;/code&gt;: the checksum matched. Docker reused the cached layer instantly. Line two, &lt;code&gt;WORKDIR /app&lt;/code&gt;: the checksum matched. Cached again. Then Docker hit line three: &lt;code&gt;COPY app.py .&lt;/code&gt;. It checked the file inside Maya’s &lt;strong&gt;&lt;code&gt;Called_me&lt;/code&gt;&lt;/strong&gt; folder, calculated a new checksum, and realized it didn't match the old layer's fingerprint.&lt;/p&gt;

&lt;p&gt;The moment that single line changed, the chain broke. Docker couldn't reuse the old &lt;code&gt;COPY&lt;/code&gt; layer, and because every layer's checksum depends on the layer beneath it, Docker had to rebuild the &lt;code&gt;COPY app.py .&lt;/code&gt; layer &lt;strong&gt;and every single layer after it&lt;/strong&gt; from scratch. It created a brand-new layer holding the updated &lt;code&gt;app.py&lt;/code&gt; inside the image's &lt;code&gt;/app&lt;/code&gt; folder, stamped it with a new checksum, and rebuilt the final &lt;code&gt;CMD&lt;/code&gt; layer on top of it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsnwdaaje6i56eabsao9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsnwdaaje6i56eabsao9b.png" alt=" " width="800" height="730"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In less than a second, the new image was ready. Maya’s computer still held her editable &lt;code&gt;Called_me&lt;/code&gt; folder where she could tweak code freely, while the new Docker image sat beside it—a fresh, read-only, independent block, ready to be shipped to Sam so it would run the exact same way on the very first try.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dangling image
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;dangling image&lt;/strong&gt; is an old, untagged Docker image (&lt;code&gt;&amp;lt;none&amp;gt;:&amp;lt;none&amp;gt;&lt;/code&gt;) that has lost its name and is no longer used by any container.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Happens in Maya's Story
&lt;/h3&gt;

&lt;p&gt;Earlier, Maya built her first image from the &lt;code&gt;Called_me&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build -t called-me:1.0 .

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later, she fixed a typo in &lt;code&gt;app.py&lt;/code&gt; and rebuilt the image using the &lt;strong&gt;exact same tag&lt;/strong&gt; (&lt;code&gt;called-me:1.0&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Because Docker images are read-only, Docker didn't overwrite her old image. Instead, it built a brand-new image and &lt;strong&gt;peeled the &lt;code&gt;called-me:1.0&lt;/code&gt; label off the old one&lt;/strong&gt; to stick it onto the new one. The old image stayed sitting on Maya's hard drive, stripped of its name—now a dangling image.&lt;/p&gt;

&lt;p&gt;When Maya runs &lt;code&gt;docker images&lt;/code&gt;, she sees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY   TAG      IMAGE ID       SIZE
called-me    1.0      9z8y7x6w5v4u   130MB   &amp;lt;-- New image (updated app.py)
&amp;lt;none&amp;gt;       &amp;lt;none&amp;gt;   a1b2c3d4e5f6   130MB   &amp;lt;-- Old image (dangling)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Clarification About Disk Space
&lt;/h3&gt;

&lt;p&gt;Looking at that table, it looks like Maya is suddenly using &lt;strong&gt;260 MB&lt;/strong&gt; (&lt;code&gt;130 MB + 130 MB&lt;/code&gt;). &lt;strong&gt;She isn't.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shared layers don't take extra space:&lt;/strong&gt; Both images share &lt;strong&gt;Layer 1&lt;/strong&gt; (&lt;code&gt;python:3.12-slim&lt;/code&gt;, ~130 MB) and &lt;strong&gt;Layer 2&lt;/strong&gt; (&lt;code&gt;WORKDIR /app&lt;/code&gt;). Docker only stores those shared layers once on disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Only unique layers take extra space:&lt;/strong&gt; The dangling image only occupies space for the layers that are &lt;em&gt;different&lt;/em&gt; from the new image. Since Maya only changed &lt;code&gt;app.py&lt;/code&gt;, the dangling image is only wasting a few kilobytes for her old &lt;strong&gt;Layer 3&lt;/strong&gt; (&lt;code&gt;COPY app.py .&lt;/code&gt;) and &lt;strong&gt;Layer 4&lt;/strong&gt; (&lt;code&gt;CMD&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When it actually becomes a problem:&lt;/strong&gt; If Maya changes heavy dependencies (like installing large Python libraries) and rebuilds with the same tag dozens of times, those unique unshared layers &lt;em&gt;do&lt;/em&gt; pile up and can quietly eat up gigabytes of disk space.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cleaning It Up
&lt;/h3&gt;

&lt;p&gt;Whenever Maya wants to clear out those nameless leftovers and reclaim the space from their unique layers, she runs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker image prune

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Docker deletes the &lt;code&gt;&amp;lt;none&amp;gt;:&amp;lt;none&amp;gt;&lt;/code&gt; image, frees the space from its unshared layers, and leaves her active &lt;code&gt;called-me:1.0&lt;/code&gt; image completely untouched.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Rebuilding with &lt;code&gt;called-me:2.0&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Command:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build -t called-me:2.0 .

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output (when Maya runs &lt;code&gt;docker images&lt;/code&gt;):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY   TAG   IMAGE ID       SIZE
called-me    2.0   9z8y7x6w5v4u   130MB
called-me    1.0   a1b2c3d4e5f6   130MB

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Note: If Maya did **not&lt;/em&gt;* edit &lt;code&gt;app.py&lt;/code&gt; before running this, both &lt;code&gt;1.0&lt;/code&gt; and &lt;code&gt;2.0&lt;/code&gt; will show the exact same &lt;code&gt;IMAGE ID&lt;/code&gt;: &lt;code&gt;a1b2c3d4e5f6&lt;/code&gt;.)*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Underlying Meaning:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Same project, new version:&lt;/strong&gt; Docker keeps this image inside the existing &lt;code&gt;called-me&lt;/code&gt; repository and simply marks it as version &lt;code&gt;2.0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No dangling image:&lt;/strong&gt; Because Maya used a new tag (&lt;code&gt;2.0&lt;/code&gt;), Docker does not strip the &lt;code&gt;1.0&lt;/code&gt; label off her old image. Both versions stay named and accessible for easy rollback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shared disk space:&lt;/strong&gt; Even though both rows show &lt;code&gt;130MB&lt;/code&gt;, Docker stores &lt;strong&gt;Layer 1&lt;/strong&gt; (&lt;code&gt;python:3.12-slim&lt;/code&gt;) and &lt;strong&gt;Layer 2&lt;/strong&gt; (&lt;code&gt;WORKDIR /app&lt;/code&gt;) only once on disk. The &lt;code&gt;2.0&lt;/code&gt; image only uses a few extra kilobytes for the updated &lt;code&gt;app.py&lt;/code&gt; layer.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Rebuilding with &lt;code&gt;called-me_hello:1.0&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Command:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build -t called-me_hello:1.0 .

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output (when Maya runs &lt;code&gt;docker images&lt;/code&gt;):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REPOSITORY        TAG   IMAGE ID       SIZE
called-me_hello   1.0   55aa66bb77cc   130MB
called-me         2.0   9z8y7x6w5v4u   130MB
called-me         1.0   a1b2c3d4e5f6   130MB

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Note: If Maya did **not&lt;/em&gt;* edit &lt;code&gt;app.py&lt;/code&gt; between &lt;code&gt;called-me:2.0&lt;/code&gt; and &lt;code&gt;called-me_hello:1.0&lt;/code&gt;, Docker reuses 100% of the cache and both tags will point to the exact same &lt;code&gt;IMAGE ID&lt;/code&gt;: &lt;code&gt;9z8y7x6w5v4u&lt;/code&gt;.)*&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Underlying Meaning:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Brand-new repository name:&lt;/strong&gt; Changing the name before the colon (&lt;code&gt;:&lt;/code&gt;) tells Docker to register this as a completely separate repository (&lt;code&gt;called-me_hello&lt;/code&gt;), treating it like a different app or experimental branch even though it came from the same &lt;code&gt;Called_me/&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Still shares base layers:&lt;/strong&gt; Despite having a different repository name, Docker still recognizes that &lt;strong&gt;Layer 1&lt;/strong&gt; and &lt;strong&gt;Layer 2&lt;/strong&gt; have identical SHA-256 checksums, so it reuses them from cache instead of duplicating &lt;code&gt;130MB&lt;/code&gt; on Maya's hard drive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protected from &lt;code&gt;docker image prune&lt;/code&gt;:&lt;/strong&gt; Because &lt;code&gt;called-me_hello:1.0&lt;/code&gt; has a valid name and tag (it is not &lt;code&gt;&amp;lt;none&amp;gt;:&amp;lt;none&amp;gt;&lt;/code&gt;), &lt;code&gt;docker image prune&lt;/code&gt; will ignore it. To delete it later, Maya must remove it manually with &lt;code&gt;docker rmi called-me_hello:1.0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>containers</category>
      <category>docker</category>
      <category>python</category>
      <category>cmd</category>
    </item>
  </channel>
</rss>
