<?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: Harshil Srivastava</title>
    <description>The latest articles on DEV Community by Harshil Srivastava (@harshil_drytu).</description>
    <link>https://dev.to/harshil_drytu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4076915%2F36768291-5e83-4fbc-be13-63d3495f9b74.gif</url>
      <title>DEV Community: Harshil Srivastava</title>
      <link>https://dev.to/harshil_drytu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshil_drytu"/>
    <language>en</language>
    <item>
      <title>From "It Works On My Machine" to Docker Mastery: A Beginner's Guide</title>
      <dc:creator>Harshil Srivastava</dc:creator>
      <pubDate>Sat, 15 Aug 2026 06:21:26 +0000</pubDate>
      <link>https://dev.to/harshil_drytu/from-it-works-on-my-machine-to-docker-mastery-a-beginners-guide-4291</link>
      <guid>https://dev.to/harshil_drytu/from-it-works-on-my-machine-to-docker-mastery-a-beginners-guide-4291</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Let's face it now. We spend hours in coding, adjusting dependencies and building a very cool app. But when you try to deploy it and send it to your friend to check out your awesomeness... &lt;strong&gt;nothing works&lt;/strong&gt;. Then your friend starts complaining that your app is asking for some modules and dependencies and then your reply is one of the most common replies in the developer field, "&lt;strong&gt;It Works On My Machine&lt;/strong&gt;". &lt;/p&gt;

&lt;p&gt;If you are tired of this situations then it looks like you need to learn about &lt;strong&gt;Docker&lt;/strong&gt;. In this blog we will try to understand what Docker is, why it was created and how it had solved one of the most problematic situations occur in software development and deployments.&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%2Fk5qjop31w16kksz1kg41.jpg" 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%2Fk5qjop31w16kksz1kg41.jpg" alt="The Overall scenario" width="422" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Pre-Docker Era: One Server, One App
&lt;/h2&gt;

&lt;p&gt;To understand why Docker is so important in today's IT industry, we need to look at history for it. In the early days when applications were used, companies ran them on physical servers in data centres. The rule was simple but inefficient: &lt;strong&gt;One application per server&lt;/strong&gt;. To understand it in simple words, &lt;strong&gt;One Laptop for One App&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;If a small amount of people (like 200) were using the application a single server was good enough to handle that. But when a big amount (like 2000) of people tries to use that application, the server might crash as it is not capable to handle that much amount of traffic. So to solve this situation companies have to buy an entirely new server, which is expensive, slow, and terrible for the environment. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Virtual Machine Era: Better, but Heavy
&lt;/h2&gt;

&lt;p&gt;Virtual Machines (VMs): If you want to run Linux OS and you have Windows OS you do not need to buy an another Laptop for it. Instead you can install an application like VirtualBox (its an open source software which lets you run a second operating system inside your current computer) and then inside that software, you open a window and turn on Linux. Look how cool it is, your Windows (Host) OS Laptop is running Linux (Guest) OS in it without buying another laptop. Even if the Linux gets a virus, you can just close or delete the virtual window, without affecting your Windows OS. &lt;/p&gt;

&lt;p&gt;Hypervisor: It helps in splitting a single physical server into multiple virtual servers.&lt;/p&gt;

&lt;p&gt;But here also we had a problem: Every VM must have its own Operating System (OS). Suppose you need to run five different or same apps then you need five different OS for each of them. This consumes massive amounts of RAM, CPU, and storage just to keep the OS alive, leaving less resources for the actual app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter Containers: The Ultimate Solution
&lt;/h2&gt;

&lt;p&gt;Tech giants like Google and Amazon realised they need isolated environments without the heavy burden of a full OS every time. This led to &lt;strong&gt;Containers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Imagine you want to ship a car, a piano, and some furniture across the world. Instead of figuring out different transport methods for each, you put them all in standardized steel boxes—containers.&lt;/p&gt;

&lt;p&gt;In software field, a container is a box that holds your application code, its dependencies, and its system libraries. It isolates the application so it has no idea what is happening outside of it. It runs directly on the host operating system's kernel, making it lightweight and super fast to start. Docker is simply the most popular platform or tool that allows us to create, deploy, and manage these containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Containers vs. Virtual Machines
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Virtual Machines: Hardware -&amp;gt; Host OS -&amp;gt; Hypervisor -&amp;gt; Guest OS -&amp;gt; Application. (Heavy, slow to start).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Containers: Hardware -&amp;gt; Host OS -&amp;gt; Container Engine (like Docker) -&amp;gt; Application. (Lightweight, starts in seconds).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you think after this container concept came there will be no need of VMs anymore, you are wrong. In today's modern Cloud Architecture, containers often run on top of virtual machines!&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%2Fn98sr5qhofp2wuazocgv.jpg" 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%2Fn98sr5qhofp2wuazocgv.jpg" alt="Containers vs VMs" width="800" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaking down: Images vs. Containers
&lt;/h2&gt;

&lt;p&gt;The two most confusing terms for beginners are Images and Containers. Here is the simple way to understand them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The Recipe Analogy: Imagine you make an amazing noodle soup. You can't ship a hot bowl of soup to your friend in another country. Instead, you send them the recipe. The recipe is the &lt;strong&gt;Docker Image&lt;/strong&gt; (the instructions). When your friend follows the recipe and makes the soup, that running soup is the &lt;strong&gt;Container&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Programming Analogy: For the coders out there, a Docker Image is a &lt;strong&gt;Class&lt;/strong&gt;, and a Container is the &lt;strong&gt;Object&lt;/strong&gt; (the running instance) of that class.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Under the Hood: Docker Architecture
&lt;/h2&gt;

&lt;p&gt;Docker operates on a Client-Server architecture.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Docker CLI (Client): This is your terminal where you type commands (like &lt;code&gt;docker run&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Daemon (Server): It listens to the CLI via REST APIs and manages Docker objects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Containerd &amp;amp; runc (Runtime): The daemon doesn't actually run the containers; it passes the job to runtimes. &lt;code&gt;runc&lt;/code&gt; is responsible for starting and stopping containers, while &lt;code&gt;containerd&lt;/code&gt; manages the image pulling and networking.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2Fqpofkechlkrrhfwhmbli.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%2Fqpofkechlkrrhfwhmbli.png" alt="Client-Daemon-Runtime architecture" width="799" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Your Hands Dirty: Essential Docker Commands
&lt;/h2&gt;

&lt;p&gt;After installing Docker Desktop, here are some commands that you will use everyday:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker run &amp;lt;image_name&amp;gt;&lt;/code&gt;: Pulls the image from Docker Hub(if you do not have it locally) and starts the container. Try &lt;code&gt;docker run hello-world&lt;/code&gt;!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker run -it ubuntu&lt;/code&gt;: Pulls the image of Ubuntu from the Docker Hub in an interactive environment so you can execute Linux commands right inside the container. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker ps&lt;/code&gt;: Lists all the running containers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker ps -a&lt;/code&gt;: Lists all the containers even the stopped ones. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker stop &amp;lt;container_id&amp;gt;&lt;/code&gt;: Stops the container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker rm &amp;lt;container_id&amp;gt;&lt;/code&gt;: Removes the container. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker images&lt;/code&gt;: Lists all the images downloaded on your local system. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Exposing your apps: Port Forwarding
&lt;/h2&gt;

&lt;p&gt;If you run a web server like Nginx inside your container using &lt;code&gt;docker run nginx&lt;/code&gt;, you would not be able to view it in your browser natively. Why? Because the container is isolated.&lt;/p&gt;

&lt;p&gt;You need to map the port from your local system to container's internal port:&lt;br&gt;
&lt;code&gt;docker run -p 8080:80 nginx&lt;/code&gt;&lt;br&gt;
This command tells the docker that, "Any traffic from localhost:8080 on my computer funnel it through the tunnel to port 80 inside the container."&lt;/p&gt;
&lt;h2&gt;
  
  
  Making Your First Image: The Dockerfile
&lt;/h2&gt;

&lt;p&gt;If an image is a recipe, then the Dockerfile is where you write that recipe. It is a simple text file in which the instructions are written to how to build your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#1. Start with the base image (ubuntu)
FROM ubuntu 

#2. Run commands during the build process
RUN apt-get update

#3. What container should do when it starts 
CMD ["echo", "Hello, My name is Docker!"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To build this image, simply run &lt;code&gt;docker build -t my-first-image .&lt;/code&gt; in the same directory. Once built, now you can share this with anyone in the world. It will work exactly the same way it did on your system.&lt;/p&gt;

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

&lt;p&gt;Docker has completely changed how we develop, ship and run software. By packaging the application into a lightweight and isolated container,   it finally puts an end of "It Works On My Machine" excuse. If you think this is the end then wait my friend it is just the tip of an iceberg. From there we will discuss Docker Compose, Docker Volume and Kubernetes in upcoming blogs.  &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>devops</category>
      <category>cloud</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
