<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kharelsuzan on Medium]]></title>
        <description><![CDATA[Stories by Kharelsuzan on Medium]]></description>
        <link>https://medium.com/@kharelsuzan456?source=rss-6fb6724e2e45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tG5t71-Ipemm4e9w</url>
            <title>Stories by Kharelsuzan on Medium</title>
            <link>https://medium.com/@kharelsuzan456?source=rss-6fb6724e2e45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:49:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kharelsuzan456/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How internet works]]></title>
            <link>https://medium.com/@kharelsuzan456/how-internet-works-64631f6764e1?source=rss-6fb6724e2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/64631f6764e1</guid>
            <category><![CDATA[data-transfer]]></category>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[it-knowledge]]></category>
            <category><![CDATA[basic-knowledge]]></category>
            <dc:creator><![CDATA[Kharelsuzan]]></dc:creator>
            <pubDate>Wed, 18 Nov 2026 07:13:39 GMT</pubDate>
            <atom:updated>2026-11-18T07:13:39.553Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wondered what really happens when you type youtube.com? In under a second, your request travels thousands of kilometers through cables, servers, and routers. Let’s break it all down — no tech background needed.<br>tags: beginners, internet, networking, webdev</p><p>Have you ever typed youtube.com into your browser and wondered what actually happens in that split second before the page loads? It feels instant, but behind the scenes, your request travels thousands of kilometers, passes through multiple servers, and returns with exactly the right content — all in under a second.</p><p>In this post, I’ll break down exactly what happens when you visit a website, in the simplest way possible — <strong>no technical background needed.</strong></p><h3>1. What Even Is the Internet?</h3><p>Before we trace your YouTube request, let’s clear one thing up. <strong>The internet is not a cloud floating somewhere in the sky.</strong> It is a massive physical network of cables, routers, and servers connecting billions of devices around the world.</p><p>A huge part of it runs through <strong>undersea fiber optic cables</strong> lying on the ocean floor — connecting continents like Europe, Asia, America, and Africa. When you watch a YouTube video in Nepal, that data likely traveled through one of these cables under the ocean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*A0tW3iAttyjSlVj-.png" /></figure><p>These cables carry data as <strong>pulses of light</strong> — not electricity. Light travels at roughly 300,000 km per second, which is why a request from Nepal can reach a server in Singapore and come back in under 50 milliseconds.</p><h3>2. IP Addresses — The Internet’s Postal System</h3><p>Every single device connected to the internet has a unique address called an <strong>IP address</strong> (Internet Protocol address). Think of it exactly like a home address — without it, nobody knows where to deliver your data.</p><p>For example:</p><ul><li>Your laptop might have a private IP like 192.168.1.5 on your home network</li><li>Google’s servers have a public IP like 142.250.190.78</li><li>YouTube’s servers have their own unique IP addresses too</li></ul><h3>Private vs Public IP</h3><p>There are actually two kinds of IP addresses:</p><p>Private IP — only works inside your home network</p><p>Your laptop: 192.168.1.2</p><p>Your phone: 192.168.1.3</p><p>Your TV: 192.168.1.4<br>Public IP — your router’s address on the internet</p><p>Your entire home shares ONE public IP</p><p>assigned by your ISP (like WorldLink or Vianet)</p><p>Example: 103.xxx.xxx.xxx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*bFkUULqmwBj3thNf.png" /></figure><p>Your router acts as a translator — it takes all your devices’ private IPs and represents them all with one public IP to the outside world. This is called <strong>NAT (Network Address Translation)</strong>.</p><h3>IPv4 — The Original System</h3><p>The original version of IP addresses is called <strong>IPv4</strong> — the “4” simply means it is the 4th version of the Internet Protocol standard. Versions 1, 2, and 3 were experimental and never widely used, so IPv4 was the first one the public internet ran on.</p><p>IPv4 addresses look like this:</p><p>192.168.1.5</p><p>142.250.190.78</p><p>103.xxx.xxx.xxx</p><ul><li><strong>Format:</strong> four numbers separated by dots</li><li><strong>Each number:</strong> 0 to 255</li><li><strong>Total possible addresses:</strong> about 4.3 billion</li></ul><p>When the internet was invented in the 1970s and 80s, 4.3 billion addresses seemed more than enough. Nobody imagined billions of people would each own multiple devices. But by the 2000s, the internet had grown so large that IPv4 addresses started <strong>running out</strong>.</p><h3>IPv6 — The Solution to Running Out</h3><p>To solve the shortage, engineers created <strong>IPv6</strong> — the “6” means it is the 6th version of the Internet Protocol (version 5 was also experimental and never publicly deployed, which is why we went from 4 to 6).</p><p>IPv6 addresses look like this:</p><p>2001:0db8:85a3:0000:0000:8a2e:0370:7334</p><ul><li><strong>Format:</strong> eight groups of hexadecimal numbers separated by colons</li><li><strong>Total possible addresses:</strong> 340,000,000,000,000,000,000,000,000,000,000,000,000 <em>(340 undecillion — basically unlimited)</em></li></ul><p>IPv6 gives every grain of sand on Earth its own IP address — billions of times over. The internet will never run out of IPv6 addresses.</p><blockquote><em>💡 </em><strong><em>IPv4:</em></strong><em> like a 4-digit phone number — ran out quickly<br></em><strong><em>IPv6:</em></strong><em> like a 20-digit phone number — will never run out</em></blockquote><p>Today most devices support both. The internet is slowly transitioning from IPv4 to IPv6, though IPv4 still handles most traffic.</p><h3>3. MAC Address — Your Device’s Permanent Identity</h3><p>While an IP address is like your current home address <em>(it can change)</em>, a <strong>MAC address</strong> (Media Access Control address) is like your fingerprint or national ID number — <strong>it never changes</strong> and is unique to you forever.</p><p>Every network device — your laptop’s WiFi card, your phone’s WiFi chip, your router — has a MAC address permanently burned into it by the manufacturer when it was built.</p><h3>What a MAC Address Looks Like</h3><p>A4:83:E7:2B:9C:1F</p><ul><li><strong>Format:</strong> six pairs of hexadecimal numbers separated by colons</li><li><strong>First three pairs</strong> = manufacturer ID → A4:83:E7 = made by Intel</li><li><strong>Last three pairs</strong> = unique device number → 2B:9C:1F = specific to your exact device</li></ul><p>You can find your own MAC address right now:</p><pre># On Mac/Linux:<br>ifconfig en0 | grep ether</pre><pre># Output:<br>ether a4:83:e7:2b:9c:1f</pre><h3>IP Address vs MAC Address — The Key Difference</h3><p><strong>IP AddressMAC AddressWhat it is</strong>Logical addressPhysical address<strong>Changes?</strong>Yes — changes per networkNo — permanent forever<strong>Who assigns it</strong>Router or ISPManufacturer<strong>Works on</strong>Entire internetLocal network only<strong>Like</strong>Your current home addressYour fingerprint<strong>Example</strong>192.168.1.5A4:83:E7:2B:9C:1F</p><h3>How They Work Together</h3><p>MAC and IP addresses work at different levels of your network:</p><p>Inside your home (MAC address used):</p><p>Your laptop → router</p><p>“Hey device with MAC D4:6E:0E, forward this for me”</p><p>MAC addresses identify devices on the LOCAL network<br>On the internet (IP address used):</p><p>Your router → YouTube’s server</p><p>“Send this data to 142.250.190.78”</p><p>IP addresses identify devices across the INTERNET</p><p>MAC addresses are invisible beyond your local network</p><blockquote><em>📦 Think of it this way — when a delivery truck (the internet) brings a package to your building (your router), it uses your building’s street address (public IP). But once inside the building, the doorman (router) uses apartment numbers (MAC addresses) to deliver to the exact flat.</em></blockquote><h3>4. DNS — The Phone Book of the Internet</h3><p><strong>DNS (Domain Name System)</strong> is the system that translates human-friendly names like youtube.com into machine-friendly IP addresses like 142.250.190.78.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*S11tAxHxNI0mZ1Nc.png" /></figure><p>Here is exactly what happens when you type youtube.com:</p><ol><li>Your browser asks: <em>“What is the IP address for youtube.com?”</em></li><li>This question goes to a <strong>DNS server</strong> (usually managed by your internet provider or Google)</li><li>The DNS server looks it up and replies: <em>“It’s 142.250.190.78”</em></li><li>Your browser now connects directly to that IP address</li><li>YouTube’s server responds and sends back the page</li></ol><p>The whole DNS lookup takes only a few milliseconds — so fast you never notice it happening.</p><blockquote><em>📖 Think of DNS like a contact book on your phone. You search for “Mom” and your phone finds her number automatically. You never need to remember the actual number.</em></blockquote><h3>5. What Are Data Packets?</h3><p>Here is something surprising — when you load YouTube, your data does not travel as one big chunk. It is broken into <strong>thousands of tiny pieces called packets</strong>.</p><p>Imagine you want to send a 1000-page book to a friend:</p><ul><li>Instead of sending the whole book at once, you tear it into individual pages</li><li>You send each page separately through different routes</li><li>Your friend receives all the pages and reassembles the book</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*NfD4xPs-GaLu_d_E.png" /></figure><p><strong>That is exactly how the internet works.</strong> Each packet:</p><ul><li>Travels independently through different routers</li><li>May take a completely different path than other packets</li><li>Gets reassembled in the correct order at the destination</li></ul><blockquote><em>🔁 This is why your internet does not completely stop if one cable breaks — packets just find another route.</em></blockquote><h3>6. TCP vs UDP — The Rules of Data Travel</h3><p>So now you know data travels as packets. But here is the next question — <strong>how does the internet make sure those packets actually arrive correctly?</strong></p><p>That depends on which <strong>protocol</strong> is being used. A protocol is simply a set of rules two devices agree to follow when communicating. The two most important ones are <strong>TCP</strong> and <strong>UDP</strong>.</p><p>Think of it like sending something to a friend:</p><blockquote><em>📮 </em><strong><em>TCP</em></strong><em> is like registered mail — slow but guaranteed. The post office confirms delivery, and if the package is lost, they resend it.</em></blockquote><blockquote><em>🪂 </em><strong><em>UDP</em></strong><em> is like dropping flyers from a plane — fast but no guarantee. Some may never land, and nobody follows up.</em></blockquote><h3>TCP — Transmission Control Protocol</h3><p>TCP is the careful, reliable protocol. Before any data is sent, your device and the server do a <strong>three-step handshake</strong> to establish a connection:</p><p>Your device → “Can we talk?” (SYN)</p><p>Server → “Yes, I am ready!” (SYN-ACK)</p><p>Your device → “Great, let us begin” (ACK)</p><p>Only after this handshake does data start flowing. TCP guarantees:</p><ul><li>✅ Every packet arrives at the destination</li><li>✅ Packets are reassembled in the correct order</li><li>✅ Any lost packet is automatically resent</li></ul><p><strong>Used for:</strong> Web browsing, emails, file downloads, online banking — anything where accuracy matters more than speed.</p><h3>UDP — User Datagram Protocol</h3><p>UDP skips the handshake entirely. It just fires packets and moves on — no confirmation, no resending, no checking.</p><p>This sounds unreliable. But it is actually perfect for real-time situations.</p><p>Imagine you are on a video call. If one frame of video gets lost mid-conversation, you do <strong>not</strong> want your app to pause and wait for that frame to be resent. By the time it arrives, it is already useless — the conversation has moved on. It is far better to just skip that frame and keep going.</p><p><strong>Used for:</strong> Video calls, live streaming, online gaming, YouTube Live — anything where speed matters more than perfection.</p><h3>TCP vs UDP: Side by Side</h3><p>TCP (Transmission Control Protocol)</p><p>Connection: A handshake is required first, so both sides agree before any data is sent.<br>Reliability: Every packet is guaranteed to arrive.<br>Order: Packets are delivered in the correct order.<br>Speed: Slower, because of all the checking.<br>Lost packets: Automatically resent.<br>Best for: Accuracy.<br>Real examples: Web pages, email, online banking.</p><p>UDP (User Datagram Protocol)</p><p>Connection: No setup. It just sends.<br>Reliability: No guarantee that packets arrive.<br>Order: Packets may arrive out of order.<br>Speed: Much faster.<br>Lost packets: Simply dropped, with no resend.<br>Best for: Speed.<br>Real examples: Video calls, online gaming, live streaming.</p><p>Which One Should You Use?</p><p>Choose TCP when every piece of data must arrive correctly, such as loading a web page or sending a payment.</p><p>Choose UDP when speed matters more than perfection, such as a video call, where a tiny glitch is better than a long delay.</p><h3>YouTube Actually Uses Both</h3><p>Here is something interesting — YouTube does not pick just one:</p><ul><li>Loading the <strong>homepage</strong> → TCP <em>(your feed, subscriptions, and thumbnails must load perfectly)</em></li><li>Watching a <strong>video</strong> → UDP <em>(a skipped frame is better than constant buffering)</em></li></ul><p>This is why on a slow connection your video goes <strong>pixelated or choppy</strong> rather than pausing completely — UDP is dropping packets and not resending them, choosing speed over perfection.</p><blockquote><em>💡 </em><strong><em>Quick summary:</em></strong><em> TCP = reliability. UDP = speed. The internet uses whichever one fits the job.</em></blockquote><h3>7. Routers — The Traffic Directors</h3><p>A <strong>router</strong> is a device that decides where each packet should go next. Your home router is a small version of this.</p><p>On the internet, there are massive industrial routers at <strong>Internet Exchange Points (IXPs)</strong> — buildings where thousands of internet cables meet and data gets redirected to the correct destination.</p><p>When your YouTube request travels from Nepal to Google’s servers, it might pass through <strong>10 to 20 different routers</strong> along the way — each one deciding the fastest next step.</p><h3>8. The Server Responds</h3><p>So your request finally reaches YouTube’s <strong>data center</strong> — a massive building full of thousands of computers called servers.</p><p>These servers:</p><ul><li>Store all of YouTube’s videos (millions of terabytes of data)</li><li>Process your request</li><li>Find the right video or page</li><li>Send the data back to you as packets</li></ul><p>YouTube alone has dozens of data centers across the world. When you are in Nepal, your request goes to the <strong>nearest data center</strong> — probably in Singapore or India — so the response comes back as fast as possible.</p><h3>9. HTTPS — Keeping Your Data Safe</h3><p>You may have noticed websites start with https:// not just http://. That <strong>S stands for Secure</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*D_J3mLHXUCziBBCL.png" /></figure><p>When data travels between your browser and a server, it is <strong>encrypted</strong> — meaning even if someone intercepts it, they cannot read it. This is especially important for:</p><ul><li>Passwords</li><li>Bank details</li><li>Private messages</li></ul><blockquote><em>⚠️ Without HTTPS, anyone on the same WiFi network as you could potentially read the data you are sending. Always check for the </em><strong><em>🔒 padlock icon</em></strong><em> in your browser before entering sensitive information.</em></blockquote><h3>10. Putting It All Together</h3><p>Let us now trace the complete journey of typing youtube.com one final time:</p><ol><li><strong>You type </strong><strong>youtube.com and press Enter</strong></li><li><strong>MAC address</strong> — your laptop sends the request to your router using the router’s MAC address on your local network</li><li><strong>NAT</strong> — your router replaces your private IP with your public IP</li><li><strong>DNS lookup</strong> — your browser finds YouTube’s IP address (IPv4 or IPv6)</li><li><strong>TCP connection</strong> — your device establishes a connection with YouTube’s server</li><li><strong>HTTPS handshake</strong> — encryption is set up between you and YouTube</li><li><strong>Request sent</strong> — your browser asks for the YouTube homepage</li><li><strong>Server responds</strong> — YouTube’s server sends back the page as packets</li><li><strong>Packets travel</strong> — through routers, undersea fiber optic cables, across thousands of kilometers</li><li><strong>Reassembled</strong> — your browser puts all packets together</li><li><strong>Page loads</strong> — YouTube appears on your screen</li></ol><p>✅ <strong>All of this happens in under one second.</strong></p><h3>Final Thoughts</h3><p>The internet is one of the most remarkable things humans have ever built. What feels like magic — a YouTube video loading instantly from a server on the other side of the world — is actually a precisely engineered system of cables, IP addresses, MAC addresses, DNS servers, packets, and routers all working together seamlessly.</p><p>Next time a page loads slowly, you will know exactly which part of this chain is taking its time. And next time you connect to a new WiFi network, you will understand why your IP address changes but your MAC address never does.</p><p><em>Did you find this helpful? Drop a comment below — I would love to hear what you thought, and what topic you would like me to explain next.</em> 🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64631f6764e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD Explained Simply: From Manual Deployment to GitHub Actions and Docker]]></title>
            <link>https://medium.com/@kharelsuzan456/ci-cd-explained-simply-from-manual-deployment-to-github-actions-and-docker-8e16ea609f84?source=rss-6fb6724e2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e16ea609f84</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[web-automation]]></category>
            <dc:creator><![CDATA[Kharelsuzan]]></dc:creator>
            <pubDate>Wed, 18 Nov 2026 07:05:31 GMT</pubDate>
            <atom:updated>2026-11-18T07:05:31.136Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A practical beginner’s guide to understanding, building, and improving an automated deployment pipeline.</em></p><p>Writing code is only one part of building software. The next challenge is delivering that code to the people who use it.</p><p>An application may work perfectly on a developer’s laptop, but it still needs to be checked, packaged, transferred to a server, and started correctly. Every update repeats that journey.</p><p>When these steps are handled manually, releasing software can become slow and inconsistent. A forgotten command or an unnoticed error can turn a small update into a broken application.</p><p><strong>CI/CD helps make this process repeatable by turning build, test, and deployment steps into automation.</strong></p><p>In this guide, we will first understand why CI/CD is useful. Then we will build a simple pipeline that checks a Node.js application and deploys it to a server using <strong>GitHub Actions and Docker</strong>.</p><h3>Why Deployment Needs a Process</h3><p><strong>Deployment means making an application — or an updated version of it — available in the environment where it will run.</strong></p><p>For a web application, that usually means running it on a server that users can access.</p><p>A typical manual deployment involves:</p><ol><li>Connecting to the server.</li><li>Downloading the latest code.</li><li>Installing dependencies or rebuilding the application.</li><li>Starting the updated version.</li><li>Checking that it works.</li></ol><p>For an application using Docker, the commands might look like this:</p><pre>ssh root@YOUR_SERVER_IP</pre><pre>cd /root/nodejs-cicd-app</pre><pre>git pull origin main</pre><pre>docker compose up --build -d</pre><pre>curl --fail <a href="http://localhost:8080/health">http://localhost:8080/health</a></pre><p>There is nothing inherently wrong with deploying manually. It can be useful when learning or setting up a project for the first time.</p><p>The difficulty appears when updates become frequent or several people work on the same application.</p><h3>The Limitations of Manual Deployment</h3><p><strong>Repeated work</strong><br>Developers must run the same commands every time they release an update. This takes time that could be spent improving the application.</p><p><strong>Forgotten steps</strong><br>Someone might download the latest code but forget to rebuild or restart the application. As a result, users may still see the old version.</p><p><strong>Inconsistent releases</strong><br>Different team members may follow different deployment procedures, making releases harder to reproduce reliably.</p><p><strong>Late discovery of bugs</strong><br>Without automated checks, a broken application may reach the server before anyone notices the problem.</p><p><strong>Difficult troubleshooting</strong><br>When something fails, it may be unclear which commands were executed or which step caused the error.</p><p><strong>Dependence on one person</strong><br>If only one person knows how deployment works, updates become difficult when that person is unavailable.The underlying problem is simple:</p><blockquote><strong><em>A process that depends on people remembering every step becomes harder to maintain as the project grows.</em></strong></blockquote><p>We need a way to describe those steps once and execute them consistently.</p><p>That is where a CI/CD pipeline comes in.</p><h3>What Is a CI/CD Pipeline?</h3><p>A <strong>pipeline</strong> is a sequence of automated tasks.</p><p>A basic software pipeline downloads the code, builds the application, runs checks, and deploys it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SoeUV9UYeU1_7ZodTYU6aA.png" /></figure><p>Each stage has a clear purpose. Later stages can depend on earlier stages succeeding.</p><p>The term <strong>CI/CD</strong> describes two related parts of this process.</p><h3>Continuous Integration: Checking Changes Regularly</h3><p><strong>Continuous Integration, or CI, means regularly combining code changes and checking them automatically.</strong></p><p>When a developer pushes a change, CI can verify that:</p><ul><li>The application builds.</li><li>Dependencies install successfully.</li><li>Tests pass.</li><li>The application starts.</li><li>Important endpoints respond.</li></ul><p>The purpose is to catch problems soon after they are introduced, while they are easier to investigate.</p><p><strong>CI is only as useful as the checks you include.</strong> A pipeline that checks whether an application starts will catch startup problems, but it will not necessarily detect incorrect business logic.</p><h3>Continuous Delivery and Continuous Deployment</h3><p>The abbreviation <strong>CD</strong> has two common meanings:</p><p>ApproachWhat happens after checks pass?</p><p><strong>Continuous Delivery: </strong>The application is ready for release, but a person approves deployment to production.</p><p><strong>Continuous Deployment: </strong>The application deploys automatically without a separate approval for each release.</p><p><strong>Production</strong> is the environment used by real users.</p><p>In this tutorial, we will use continuous deployment: a successful push to the main branch will lead to an automatic server update.</p><blockquote><strong><em>CI checks whether a change meets your requirements. CD moves that change toward release.</em></strong></blockquote><h3>How CI/CD Helps — and What It Does Not Solve</h3><p>A well-designed pipeline offers several practical benefits.</p><p><strong>Consistency:</strong> Every change follows the same configured steps.</p><p><strong>Faster feedback:</strong> Developers see failed checks shortly after pushing code.</p><p><strong>Less repetitive work:</strong> Routine deployment commands run automatically.</p><p><strong>Better visibility:</strong> Logs show which steps ran and where problems occurred.</p><p><strong>Shared knowledge:</strong> The deployment process lives in a file that the team can review and improve.</p><p>However, automation is not a guarantee of correctness.</p><p>A pipeline can contain mistakes. Tests can miss bugs. A production server can fail even after CI succeeds.</p><p>Pipelines also require maintenance, and their builds consume computing resources.</p><p><strong>The goal is not to eliminate every possible failure. It is to make changes easier to check, release, and troubleshoot.</strong></p><h3>Tools Used for CI/CD</h3><p>CI/CD is a practice, not a particular product. Several tools can automate the steps involved in building, testing, and deploying an application.</p><p><strong>GitHub Actions</strong><br>An automation tool integrated with GitHub. You define workflows inside your repository to run checks and deploy your application.</p><p><strong>Jenkins</strong><br>An automation server you configure and manage. It allows you to build customizable pipelines for testing and deploying software.</p><p><strong>GitLab CI/CD</strong><br>A pipeline tool integrated with GitLab. It runs automated builds, tests, and deployments using instructions stored in your repository.</p><p><strong>Azure Pipelines</strong><br>A service within Azure DevOps that automates building, testing, and deploying applications.</p><p>For this tutorial, we will use <strong>GitHub Actions</strong> because it lets us keep our application code and automation instructions in the same repository.</p><p>Before creating the workflow, let us understand <strong>Docker</strong> and how it helps package our application for deployment.</p><h3>Understanding Docker Before Using It</h3><p>An application needs more than its source code.</p><p>Our example needs:</p><ul><li>A Node.js runtime.</li><li>Application files.</li><li>Dependencies such as Express.</li><li>A command that starts the application.</li></ul><p>If those requirements differ between machines, the application may behave differently.</p><p><strong>Docker packages the application and its runtime requirements into an image.</strong></p><p>That image can then be used to start a container.</p><h3>Dockerfile, Image, and Container</h3><p>These three terms describe different things:</p><p>TermSimple explanation</p><p><strong>Dockerfile:</strong>A file containing instructions for building an image.</p><p><strong>Image:</strong>A packaged application with the files and runtime it needs.</p><p><strong>Container:</strong>A running instance of an image.</p><p>A useful comparison is a recipe:</p><ul><li>The <strong>Dockerfile</strong> is the recipe.</li><li>The <strong>image</strong> is the prepared package.</li><li>The <strong>container</strong> is that package running as an application.</li></ul><p><strong>Docker helps reproduce the application’s environment.</strong> It does not make network settings, credentials, or server resources identical.</p><h3>What Is Docker Compose?</h3><p>Docker Compose describes how containers should run.</p><p>For example, it can specify:</p><ul><li>Which image to build.</li><li>Which ports to expose.</li><li>Which environment variables to provide.</li><li>Whether a container should restart.</li></ul><p>These settings go into a YAML file. <strong>YAML is a text format that uses indentation to organize configuration.</strong></p><p>Our application needs only one container, but Compose still gives us a convenient, repeatable way to start it.</p><h3>The Application and Pipeline We Will Build</h3><p>We will create a small Node.js application using <strong>Express</strong>, a framework for handling HTTP requests.</p><p>It will provide two endpoints:</p><p>Endpoint Purpose/Returns a simple application message./healthConfirms that the application can respond to a request.</p><p>The pipeline will have two jobs:</p><ol><li><strong>Check:</strong> Build the application, start it, and request its health endpoint.</li><li><strong>Deploy:</strong> Update the server only if the check succeeds.</li></ol><h3>What You Need</h3><p>To follow along, you need:</p><ul><li>Node.js and npm on your computer.</li><li>Docker with Docker Compose.</li><li>Git and a GitHub repository.</li><li>An Ubuntu server with SSH access.</li><li>Git, Docker, and Docker Compose installed on that server.</li></ul><p>A <strong>VPS</strong>, or virtual private server, is a rented virtual machine that can run your application.</p><p>This example assumes a public GitHub repository. A private repository also requires a way for the server to authenticate when downloading code.</p><h3>Step 1: Create the Node.js Application</h3><p>Create a project directory:</p><pre>mkdir nodejs-cicd-app<br>cd nodejs-cicd-app</pre><p>Initialize the project and install Express:</p><pre>npm init -y<br>npm install express</pre><p>Configure JavaScript modules and the start command:</p><pre>npm pkg set type=module<br>npm pkg set scripts.start=&quot;node index.js&quot;</pre><p>Create index.js:</p><pre>import express from &#39;express&#39;;</pre><pre>const app = express();<br>const PORT = process.env.PORT || 8080;</pre><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.json({<br>    message: &#39;Application is running&#39;,<br>  });<br>});</pre><pre>app.get(&#39;/health&#39;, (req, res) =&gt; {<br>  res.json({<br>    status: &#39;ok&#39;,<br>  });<br>});</pre><pre>app.listen(PORT, () =&gt; {<br>  console.log(`Server running on port ${PORT}`);<br>});</pre><p>Start the application:</p><pre>npm start</pre><p>Open this address in your browser:</p><pre>http://localhost:8080</pre><p>You should receive:</p><pre>{&quot;message&quot;:&quot;Application is running&quot;}</pre><h3>Why Include /health?</h3><p>The pipeline needs a simple way to ask:</p><p><strong>“Has the application started, and can it respond?”</strong></p><p>The /health endpoint provides that basic signal.</p><p>This is called a <strong>smoke test</strong>: a quick check that the application’s essential startup behavior works.</p><p>It does not replace tests for individual features.</p><p>Stop the application with <strong>Ctrl+C</strong> before running the Docker container on the same port.</p><h3>Step 2: Package the Application with Docker</h3><p>Create a file named Dockerfile:</p><pre>FROM node:22-alpine</pre><pre>WORKDIR /app</pre><pre>COPY package*.json ./</pre><pre>RUN npm ci --omit=dev</pre><pre>COPY . .</pre><pre>EXPOSE 8080</pre><pre>CMD [&quot;npm&quot;, &quot;start&quot;]</pre><h3>What Each Instruction Does</h3><p>Instruction Explanation<br>FROM node:22-alpineUses a base image containing Node.js.</p><p>WORKDIR /appSets the working directory inside the image.</p><p>COPY package*.json ./Copies the dependency files.</p><p>RUN npm ci --omit=devInstalls the recorded production dependencies.</p><p>COPY . .Copies the application files.</p><p>EXPOSE 8080Documents the port the application uses.</p><p>CMD [&quot;npm&quot;, &quot;start&quot;]Defines the command used when the container starts.</p><p><strong>Commit </strong><strong>package-lock.json along with </strong><strong>package.json.</strong> The npm ci command relies on the lockfile.</p><p>We copy dependency files before application files so Docker can often reuse the dependency installation layer when only the source code changes.</p><h3>Exclude Files That Do Not Belong in the Image</h3><p>Create .dockerignore:</p><pre>node_modules<br>.git<br>.github<br>.env<br>*.log<br>id_rsa_deploy*</pre><p>This prevents those files from entering the Docker build context.</p><p>Create .gitignore as well:</p><pre>node_modules/<br>.env<br>*.log<br>id_rsa_deploy*</pre><p><strong>Local dependencies, private keys, and environment secrets should not be committed to Git.</strong></p><h3>Step 3: Configure Docker Compose</h3><p>Create docker-compose.yaml:</p><pre>services:<br>  app:<br>    build: .<br>    ports:<br>      - &quot;8080:8080&quot;<br>    restart: unless-stopped</pre><p>Here is what the configuration means:</p><ul><li><strong>app</strong> names the service.</li><li><strong>build: .</strong> builds an image from the current directory.</li><li><strong>8080:8080</strong> maps the host’s port 8080 to the container’s port 8080.</li><li><strong>restart: unless-stopped</strong> configures Docker to restart the container unless it was explicitly stopped.</li></ul><p>Start the application:</p><pre>docker compose up --build -d</pre><p>PartMeaningupCreate and start the service.--buildBuild the image before starting.-dRun in the background.</p><p>Check the health endpoint:</p><pre>curl --fail http://localhost:8080/health</pre><p>Expected response:</p><pre>{&quot;status&quot;:&quot;ok&quot;}</pre><p>The --fail option makes curl report failure for HTTP error responses, which is useful in automation.</p><p>To inspect application logs:</p><pre>docker compose logs app</pre><p>To stop the application:</p><pre>docker compose down</pre><p>Push the project files to a GitHub repository with a main branch before continuing.</p><h3>Step 4: Prepare the Deployment Server</h3><p>Connect to your server:</p><pre>ssh root@YOUR_SERVER_IP</pre><p>This tutorial uses root to keep the example short. A production setup should use a dedicated deployment account with appropriate permissions.</p><p>Verify that the required tools are available:</p><pre>git --version<br>docker --version<br>docker compose version</pre><p>If Docker is not installed, follow the <a href="https://docs.docker.com/engine/install/ubuntu/">official Ubuntu installation instructions</a>.</p><p>Clone the repository:</p><pre>git clone https://github.com/YOUR_USERNAME/nodejs-cicd-app.git</pre><pre>cd /root/nodejs-cicd-app</pre><p>Start the application:</p><pre>docker compose up --build -d</pre><p>Test it from the server:</p><pre>curl --fail http://localhost:8080/health</pre><p>To access it from your computer, allow TCP port 8080 through the relevant server and cloud firewall settings, then visit:</p><pre>http://YOUR_SERVER_IP:8080</pre><p>This example uses HTTP for learning. Configure HTTPS before using the application as a public production service.</p><p><strong>The initial deployment is now complete. Next, we will automate future updates.</strong></p><h3>Step 5: Configure SSH Access for GitHub Actions</h3><p>The deployment job needs permission to connect to the server.</p><p>We will use a dedicated <strong>SSH key pair</strong>:</p><ul><li>The <strong>public key</strong> goes on the server.</li><li>The <strong>private key</strong> goes into a GitHub secret.</li></ul><h3>Generate the Key Pair</h3><p>Run this on your computer, outside the project directory:</p><pre>ssh-keygen -t rsa -b 4096 -C &quot;github-actions-deploy&quot; -f id_rsa_deploy</pre><p>For this example, leave the passphrase empty.</p><p>This creates:</p><pre>id_rsa_deploy<br>id_rsa_deploy.pub</pre><h3>Add the Public Key to the Server</h3><p>On your computer:</p><pre>cat id_rsa_deploy.pub</pre><p>Copy the output.</p><p>On the server:</p><pre>mkdir -p ~/.ssh<br>chmod 700 ~/.ssh</pre><pre>nano ~/.ssh/authorized_keys</pre><p>Paste the public key on a new line without removing existing keys. Save the file, then run:</p><pre>chmod 600 ~/.ssh/authorized_keys</pre><p>Test the connection from your computer:</p><pre>ssh -i id_rsa_deploy root@YOUR_SERVER_IP</pre><p>Confirm that it works before proceeding.</p><h3>Add GitHub Secrets</h3><p>In your repository, open:</p><p><strong>Settings → Secrets and variables → Actions → New repository secret</strong></p><p>Create these secrets:</p><p>Secret nameValueSSH_HOSTYour server’s public IP address.SSH_KEYThe complete contents of the private key file.</p><p>Display the private key locally with:</p><pre>cat id_rsa_deploy</pre><p>Copy everything, including the opening and closing lines.</p><p><strong>Never place the private key directly in your workflow or application code.</strong></p><h3>Step 6: Understand the Workflow Structure</h3><p>GitHub Actions uses a few terms:</p><p><strong>Workflow: </strong>The complete automation process.</p><p><strong>Trigger: </strong>The event that starts the workflow.</p><p><strong>Job: </strong>A group of steps executed on a runner.</p><p><strong>Step: </strong>An individual command or reusable action.</p><p><strong>Runner: </strong>The machine executing a job.</p><p>We will use GitHub-hosted Ubuntu runners.</p><p><strong>The runner and your server have different roles.</strong> The runner performs automation; the server hosts the application for users.</p><pre>flowchart TD<br>    A[&quot;GitHub receives a push&quot;] --&gt; B[&quot;Check job: build and test&quot;]<br>    B --&gt; C[&quot;Deploy job: connect using SSH&quot;]<br>    C --&gt; D[&quot;Server: update and check the app&quot;]</pre><p>The deployment job will depend on the check job succeeding.</p><h3>Step 7: Write the GitHub Actions Workflow</h3><p>Create the workflow directory:</p><pre>mkdir -p .github/workflows</pre><p>Create .github/workflows/deploy.yaml:</p><pre>name: Check and Deploy</pre><pre>on:<br>  push:<br>    branches:<br>      - main</pre><pre>permissions:<br>  contents: read</pre><pre>concurrency:<br>  group: production<br>  cancel-in-progress: false</pre><pre>jobs:<br>  check:<br>    runs-on: ubuntu-latest</pre><pre>    steps:<br>      - name: Download repository code<br>        uses: actions/checkout@v4</pre><pre>      - name: Build and start the application<br>        run: docker compose up --build -d</pre><pre>      - name: Check application health<br>        run: |<br>          for attempt in $(seq 1 15); do<br>            if curl --fail --max-time 3 \<br>              <a href="http://localhost:8080/health;">http://localhost:8080/health;</a> then<br>              exit 0<br>            fi</pre><pre>            sleep 2<br>          done</pre><pre>          exit 1</pre><pre>      - name: Show logs on failure<br>        if: failure()<br>        run: docker compose logs</pre><pre>      - name: Clean up containers<br>        if: always()<br>        run: docker compose down</pre><pre>  deploy:<br>    needs: check<br>    runs-on: ubuntu-latest</pre><pre>    steps:<br>      - name: Deploy to the server<br>        uses: appleboy/ssh-action@v1.2.0<br>        env:<br>          DEPLOY_SHA: ${{ github.sha }}<br>        with:<br>          host: ${{ secrets.SSH_HOST }}<br>          username: root<br>          key: ${{ secrets.SSH_KEY }}<br>          envs: DEPLOY_SHA<br>          script: |<br>            set -eu</pre><pre>            cd /root/nodejs-cicd-app</pre><pre>            git fetch origin main<br>            git checkout --detach &quot;$DEPLOY_SHA&quot;</pre><pre>            docker compose up --build -d</pre><pre>            for attempt in $(seq 1 15); do<br>              if curl --fail --max-time 3 \<br>                <a href="http://localhost:8080/health;">http://localhost:8080/health;</a> then<br>                echo &quot;Deployment health check passed.&quot;<br>                exit 0<br>              fi</pre><pre>              sleep 2<br>            done</pre><pre>            docker compose logs --tail=100 app<br>            exit 1</pre><p>Change the server path if your application lives somewhere else.</p><h3>Understanding the Important Parts</h3><p><strong>The trigger</strong></p><pre>on:<br>  push:<br>    branches:<br>      - main</pre><p>The workflow starts when code is pushed to main.</p><p><strong>The check job</strong></p><p>It downloads the repository, builds the Docker image, starts the container, and requests /health.</p><p>The health check retries because applications may need a little time to start.</p><p><strong>The deployment dependency</strong></p><pre>needs: check</pre><p>This means:</p><blockquote><strong><em>Run deployment only after the check job succeeds.</em></strong></blockquote><p><strong>The deployment commit</strong></p><pre>DEPLOY_SHA: ${{ github.sha }}</pre><p>A commit SHA identifies a specific version of the code.</p><p>The deployment script selects that version:</p><pre>git fetch origin main<br>git checkout --detach &quot;$DEPLOY_SHA&quot;</pre><p>This prevents the server from accidentally deploying a newer commit than the one checked by this workflow.</p><p>Treat the server directory as a deployment copy rather than a place to edit source code manually.</p><p><strong>The failure behavior</strong></p><pre>set -eu</pre><p>This stops the remote script when a command fails or an unset variable is used.</p><p><strong>The deployment concurrency setting</strong></p><pre>concurrency:<br>  group: production<br>  cancel-in-progress: false</pre><p>This prevents workflows in this group from running at the same time, reducing the risk of overlapping deployments.</p><p><strong>The final health check</strong></p><p>The server is checked after the update because starting a container in the background does not prove that the application remains running.</p><p>A failed check reports a failed deployment. <strong>It does not automatically restore the previous version.</strong></p><h3>Step 8: Test the Complete Pipeline</h3><p>Make a small, visible change to the application response:</p><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.json({<br>    message: &#39;Application deployed through GitHub Actions&#39;,<br>  });<br>});</pre><p>Commit and push:</p><pre>git add .<br>git commit -m &quot;Add automated deployment workflow&quot;<br>git push origin main</pre><p>Open the repository’s <strong>Actions</strong> tab.</p><p>You should see:</p><ol><li>The check job building and checking the application.</li><li>The deploy job starting after the check succeeds.</li><li>Logs and a final result for each job.</li></ol><p>When deployment finishes, request the server:</p><pre>curl --fail http://YOUR_SERVER_IP:8080</pre><p>Expected response:</p><pre>{&quot;message&quot;:&quot;Application deployed through GitHub Actions&quot;}</pre><p><strong>The update has moved from your computer to the server through the pipeline.</strong></p><h3>What Happens When a Check Fails?</h3><p>A pipeline is useful because it can stop a bad change before deployment.</p><p>On a learning project, try changing the start command in package.json to:</p><pre>&quot;scripts&quot;: {<br>  &quot;start&quot;: &quot;node nonexistent.js&quot;<br>}</pre><p>The Dockerfile uses npm start, so the container will attempt to run a file that does not exist.</p><p>After pushing this change:</p><p>StageExpected resultImage buildMay succeed.Application startupFails.Health checkFails because the application cannot respond.DeploymentSkipped.</p><p><strong>Building an image successfully is different from running a working application.</strong></p><p>Because the check fails before deployment begins, the existing server application is left untouched.</p><p>Restore the correct start command afterward:</p><pre>&quot;scripts&quot;: {<br>  &quot;start&quot;: &quot;node index.js&quot;<br>}</pre><p>Then commit and push the fix.</p><h3>Common Beginner Problems</h3><p>When a pipeline fails, check these first.</p><p>Workflow does not start<br>Confirm the file is inside the .github/workflows/ folder and that you pushed to the main branch.</p><p>YAML error<br>Check the indentation and use spaces rather than tabs.</p><p>npm ci fails<br>Confirm package-lock.json is committed and matches package.json.</p><p>SSH connection fails<br>Verify the host, username, key, and that the server accepts SSH access.</p><p>Application starts but the health check fails<br>Inspect the container logs, the port mapping, and the /health route.</p><p>Server cannot download the repository<br>Check repository access and authentication.</p><p>Application works on the server but not externally<br>Check the firewall rules and make sure the public port is open.</p><p>Start with the first failed step in the workflow logs. Later errors are often consequences of that first failure.</p><h3>How to Improve This Pipeline</h3><p>This tutorial provides a working foundation. A production pipeline usually adds more safeguards.</p><h3>Test Application Behavior</h3><p>Add unit and integration tests. A health check only confirms basic responsiveness.</p><h3>Build Once and Deploy the Same Image</h3><p>Our example builds in CI and rebuilds on the server.</p><p>A stronger approach builds an image once, tests it, stores it in a container registry, and deploys that exact image.</p><p><strong>A container registry is a service that stores Docker images.</strong></p><h3>Add Rollback Support</h3><p>Keep a previous working image available so a failed release can be reversed.</p><h3>Check Pull Requests</h3><p>Run checks before code reaches main, and require them before merging.</p><h3>Strengthen Deployment Access</h3><p>Use a dedicated deployment account, verify the SSH server’s identity, and pin third-party actions to reviewed commit SHAs.</p><h3>Monitor the Running Application</h3><p>Deployment checks are brief. Monitoring helps detect problems that appear later.</p><h3>## Bringing It All Together</h3><p>Each part of our setup has a specific responsibility:</p><p>- **GitHub:** Stores application code.<br>- **Dockerfile:** Defines how to package the application.<br>- **Docker:** Builds images and runs containers.<br>- **Docker Compose:** Defines how the container runs.<br>- **GitHub Actions:** Executes checks and deployment steps.<br>- **SSH:** Connects the deployment job to the server.<br>- **Server:** Runs the application for users.</p><p>CI/CD becomes easier to understand when viewed as a practical answer to a familiar problem: releasing code reliably without repeating the same manual work.</p><p>Start with a small application. Automate its build. Add a meaningful check. Make deployment depend on that check.</p><p>Then improve the pipeline as the application grows.</p><p>The value is not in having a complicated workflow. It is in having a process you understand, can repeat, and can trust within the limits of what it checks.</p><p>**What part of CI/CD was hardest to understand when you started? Share your questions or experience in the comments.**</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e16ea609f84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Containerization and Docker — A Complete Beginner’s Guide]]></title>
            <link>https://medium.com/@kharelsuzan456/containerization-and-docker-a-complete-beginners-guide-b5ac970c462a?source=rss-6fb6724e2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5ac970c462a</guid>
            <dc:creator><![CDATA[Kharelsuzan]]></dc:creator>
            <pubDate>Sat, 25 Jul 2026 08:53:15 GMT</pubDate>
            <atom:updated>2026-07-25T18:10:14.708Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*iYsLt8Y7cBxyiXrg.png" /></figure><p>I recently deployed my first backend using Docker and pushed it<br>to Azure — and honestly, before I started, Docker felt like one<br>of those things that only “real” engineers use.</p><p>It is not. It is actually one of the most practical tools you<br>can learn as a developer, and once the core idea clicks,<br>everything else follows naturally.</p><p>In this post I am going to explain Docker and containerization<br>from absolute zero — the problem it solves, how it works under<br>the hood, and why developers use it every single day in real jobs.</p><p>Let us start from the very beginning.</p><h3>The Problem — “It Works On My Machine”</h3><p>Imagine this situation.</p><p>You spend three days building a web application on your laptop.<br>Everything works perfectly. You send the code to your teammate<br>or upload it to a server, and within minutes they message you:</p><blockquote>“It is not working.”</blockquote><blockquote>You look at their screen. Same code. Same project. But it crashes<br>immediately.</blockquote><p>After an hour of debugging you discover the issue — you have<br><strong>Node.js version 20</strong> installed on your laptop but the server<br>is running <strong>Node.js version 16</strong>. Or maybe a package you<br>installed globally on your machine is missing on theirs. Or<br>the environment variables are set up differently.</p><p>This situation is so frustratingly common in software development<br>that it has its own famous joke:</p><blockquote><strong><em>“It works on my machine!”</em></strong></blockquote><blockquote><em>— Every developer, at some point</em></blockquote><p>This is not a small inconvenience. In real teams, this problem<br>wastes enormous amounts of time. Developers spend hours trying<br>to replicate environments, set up configurations, and figure out<br>why the same code behaves differently on different computers.</p><p>Docker was built specifically to kill this problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*qzVixQWsHV0SVoOr.png" /></figure><h3>The Shipping Container Analogy</h3><p>Before we get into any technical details, I want you to<br>understand the core idea through a real world analogy — because<br>this analogy is actually where Docker gets its name and logo.</p><h3>Before Shipping Containers Existed</h3><p>Imagine it is the 1950s and you need to ship goods from Nepal<br>to the United States.</p><p>Loading a ship back then was absolute chaos. You had:</p><ul><li>Wooden crates of different sizes</li><li>Bags of grain</li><li>Fragile glass items</li><li>Heavy machinery</li></ul><p>Every single item needed to be handled differently. Dock workers<br>had to manually figure out how to fit everything onto the ship.<br>Loading one ship could take <strong>weeks</strong>. Things got damaged, lost,<br>or loaded incorrectly all the time.</p><h3>After Shipping Containers</h3><p>Then in 1956, a standard shipping container was invented — a<br>simple metal box of fixed dimensions.</p><p>Suddenly everything changed:</p><ul><li>Pack your goods into the standard box, seal it</li><li>Every ship, truck, and crane is built to handle that one standard size</li><li>It does not matter what is inside — electronics, food, furniture — the handling process is always identical</li><li>A ship that used to take weeks to load could now be loaded in <strong>hours</strong></li></ul><p>The container created a <strong>standard interface</strong> between your<br>goods and the transportation system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*qqA7pDGUPxH1f0No.png" /></figure><h3>How This Maps to Docker</h3><p>Docker containers work exactly the same way.</p><p>Before Docker:</p><p>Your Laptop (Windows or Mac)<br>├── Host Operating System<br>├── VM 1 → Full Ubuntu Linux OS → Your App<br>├── VM 2 → Full Ubuntu Linux OS → Another App<br>└── VM 3 → Full Ubuntu Linux OS → Another App</p><h3>The Problem with VMs</h3><p>VMs solve the consistency problem but come with significant<br>costs:</p><ul><li><strong>Heavy</strong> — each VM needs 5GB to 20GB just for the operating system alone</li><li><strong>Slow to start</strong> — booting a full OS takes 1 to 5 minutes</li><li><strong>Wasteful</strong> — running 5 VMs means 5 full operating systems consuming your resources simultaneously</li><li><strong>Expensive</strong> — cloud providers charge significantly more for VM-level resources</li></ul><h3>How Containers Are Different</h3><p>Containers take a fundamentally different approach. Instead of<br>virtualizing an entire computer, containers share the host<br>operating system’s core (called the <strong>kernel</strong>) while keeping<br>the application completely isolated.</p><p>Your Laptop (Windows, Mac, or Linux)<br>├── Host Operating System (shared kernel)<br>├── Container 1 → Your App (no separate OS needed)<br>├── Container 2 → Another App (no separate OS needed)<br>└── Container 3 → Another App (no separate OS needed)</p><p>The result:</p><p>FeatureVirtual MachineContainerSize5GB — 20GB50MB — 500MBStartup time1–5 minutesSeconds or millisecondsOS overheadFull OS per VMShared host OSIsolationCompleteProcess-levelPerformanceSlowerNear native speedUse caseFull OS neededApp deployment</p><h3>The Apartment Analogy</h3><p>Think of it this way:</p><p>A <strong>Virtual Machine</strong> is like renting an entire apartment<br>building just because you need one room. You have your own<br>plumbing, your own electrical system, your own everything — <br>but most of it is wasted.</p><p>A <strong>Container</strong> is like renting just the room you need, sharing<br>the building’s plumbing and electricity with other tenants.<br>You still have complete privacy in your room, but you are<br>not wasting resources on infrastructure you do not need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*j4hQbUM_LJYboh09.png" /></figure><h3>Core Docker Concepts</h3><p>Now that you understand the why, let us understand the what.</p><p>Docker has four core concepts that everything else builds on.<br>Understand these four things and Docker will make complete sense.</p><h3>1. Dockerfile</h3><p>A Dockerfile is a plain text file containing step-by-step<br>instructions for building your application’s environment.</p><p>Think of it as a recipe. If you want to bake a cake, you write<br>down every ingredient and every step. The Dockerfile is that<br>recipe — it tells Docker exactly what to do to prepare your<br>application.</p><p>Here is a simple Dockerfile for a Node.js application:</p><pre># Step 1 — Start with an official Node.js base<br># This is like starting your recipe with a pre-made dough<br>FROM node:20-alpine</pre><pre># Step 2 — Set the working directory inside the container<br># Like choosing which shelf in your kitchen to work on<br>WORKDIR /app</pre><pre># Step 3 — Copy package.json first (for caching efficiency)<br>COPY package*.json ./</pre><pre># Step 4 — Install dependencies inside the container<br>RUN npm install</pre><pre># Step 5 — Copy the rest of your application code<br>COPY . .</pre><pre># Step 6 — Tell Docker which port your app runs on<br>EXPOSE 3000</pre><pre># Step 7 — The command to start your application<br>CMD [&quot;node&quot;, &quot;app.js&quot;]</pre><p>Every line in a Dockerfile creates a new <strong>layer</strong> in the image.<br>Docker is smart about caching these layers — if your code<br>changes but your packages did not, Docker reuses the cached<br>npm install step instead of running it again. This is why we<br>copy package.json before copying all our code.</p><h3>2. Image</h3><p>An image is what you get after running your Dockerfile — a<br>frozen, read-only snapshot of your application and everything<br>it needs to run.</p><p>Think of an image as the <strong>cake after baking but before serving</strong>.<br>It is complete and ready, but it is not actively doing anything yet.</p><p>You can:</p><ul><li>Store images and share them</li><li>Push them to registries like Docker Hub or Azure Container Registry</li><li>Create multiple running instances from one image</li></ul><p>To build an image from your Dockerfile:</p><pre>docker build -t my-app .</pre><ul><li>docker build — build an image</li><li>-t my-app — name it &quot;my-app&quot;</li><li>. — look for Dockerfile in current directory</li></ul><h3>3. Container</h3><p>A container is a running instance of an image. When you run<br>an image, Docker creates a container — a live, isolated process<br>with its own filesystem, network, and resources.</p><p>Think of it as <strong>actually serving and eating the cake</strong>. The<br>image was the baked cake — the container is the slice on<br>someone’s plate being consumed.</p><p>The key relationship:</p><p>Dockerfile (recipe)<br>↓ docker build<br>Image (baked cake — ready but static)<br>↓ docker run<br>Container (slice on plate — alive and running)</p><p>If you are familiar with object oriented programming, this<br>maps perfectly:</p><p>Image = Class (the blueprint)<br>Container = Object (the instance)</p><p>One image can run as many containers simultaneously as your<br>hardware allows.</p><p>To run a container from your image:</p><pre>docker run -p 3000:3000 my-app</pre><ul><li>docker run — create and start a container</li><li>-p 3000:3000 — map port 3000 on your laptop to port 3000 inside the container</li><li>my-app — which image to use</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*vk2l6iBgxF_4Abmn.png" /></figure><h3>4. Docker Hub</h3><p>Docker Hub is a public registry for Docker images — think of<br>it as GitHub but for images instead of code.</p><p>When you write FROM node:20-alpine in your Dockerfile, Docker<br>automatically downloads the official Node.js image from Docker<br>Hub. You did not install Node.js yourself — it came<br>pre-packaged in that base image.</p><p>You can also push your own images to Docker Hub and share them<br>with the world, or use them across different machines and servers.</p><pre># Push your image to Docker Hub<br>docker push yourusername/my-app:latest</pre><pre># Pull an image from Docker Hub<br>docker pull yourusername/my-app:latest</pre><h3>What Actually Happens When You Run Docker</h3><p>Let me trace the complete journey so you can see exactly<br>what happens at each step.</p><p>You write a Dockerfile<br>↓<br>docker build → Docker reads Dockerfile top to bottom<br>→ downloads base image from Docker Hub<br>→ runs each instruction as a layer<br>→ saves the result as an IMAGE<br>↓<br>docker run → Docker takes the image<br>→ creates an isolated environment<br>→ injects environment variables<br>→ maps ports<br>→ starts your application<br>→ CONTAINER is now running<br>↓<br>Your app runs inside the container<br>completely isolated from your host machine<br>↓<br>docker stop → container stops<br>docker rm → container is removed<br>(your laptop has zero leftover files or packages)</p><p>The isolation point is worth emphasizing. When your container<br>is deleted, your host machine has absolutely no trace of what<br>was running inside it. No leftover Node.js packages, no config<br>files, nothing. This is one of the most powerful aspects of<br>containerization.</p><h3>Important Docker Files</h3><h3>.dockerignore</h3><p>Just like .gitignore tells Git which files to exclude from<br>version control, .dockerignore tells Docker which files NOT<br>to copy into the container when building the image.</p><p>Create a file called .dockerignore in the same directory as<br>your Dockerfile:</p><p>node_modules<br>.env<br>.env.local<br>.git<br>.gitignore<br>.log<br>npm-debug.log<br>README.md</p><p><strong>Why each entry matters:</strong></p><p><strong>node_modules</strong> — This is the most important one. Your<br>container runs npm install itself and creates its own<br>node_modules inside the container. If you copy your local<br>node_modules into the container, you could end up with<br>incorrect packages built for the wrong operating system<br>(especially common on Mac where packages sometimes compile<br>differently than on Linux).</p><p><strong>.env</strong> — Your .env file contains sensitive information<br>like database passwords and API keys. You should <strong>never</strong><br>put secrets inside a Docker image. Images can be shared,<br>pushed to registries, and accessed by others. Instead,<br>environment variables are passed to the container at runtime<br>using the -e flag.</p><pre># Pass environment variables at runtime — NOT baked into image<br>docker run -p 3000:3000 \<br>  -e DATABASE_URL=&quot;your_database_url&quot; \<br>  -e API_KEY=&quot;your_api_key&quot; \<br>  my-app</pre><p><strong>.git</strong> — Your git history has no purpose inside a running<br>container. Including it just bloats your image size unnecessarily.</p><p><strong>*.log</strong> — Log files from your local development are not<br>needed in the container.</p><p>Not having a .dockerignore does not break Docker — but your<br>images will be larger and potentially insecure if you accidentally<br>include sensitive files.</p><h3>docker-compose.yml</h3><p>As your application grows, you will often run multiple containers<br>together. For example a real application might need:</p><ul><li>A container for your backend API</li><li>A container for your database</li><li>A container for your frontend</li></ul><p>Running each with a separate docker run command with all its<br>flags would be tedious and error-prone. This is where<br><strong>Docker Compose</strong> comes in.</p><p>Docker Compose lets you define all your containers, their<br>settings, and how they connect to each other in a single YAML<br>file called docker-compose.yml.</p><p>Here is an example for a backend API with a PostgreSQL database:</p><pre>version: &#39;3.8&#39;</pre><pre>services:<br>  # Your backend API container<br>  backend:<br>    build: .                    # build from Dockerfile in current folder<br>    ports:<br>      - &quot;3001:3001&quot;             # map port 3001<br>    environment:<br>      - DATABASE_URL=postgresql://postgres:password@db:5432/myapp<br>      - PORT=3001<br>    depends_on:<br>      - db                      # wait for database to start first</pre><pre>  # PostgreSQL database container  <br>  db:<br>    image: postgres:15          # use official PostgreSQL image<br>    environment:<br>      - POSTGRES_USER=postgres<br>      - POSTGRES_PASSWORD=password<br>      - POSTGRES_DB=myapp<br>    volumes:<br>      - postgres_data:/var/lib/postgresql/data  # persist data</pre><pre>volumes:<br>  postgres_data:                # named volume for database persistence</pre><p>Now instead of running two separate commands with long flags,<br>you just run:</p><pre># Start all containers defined in docker-compose.yml<br>docker compose up</pre><pre># Start in background (detached mode)<br>docker compose up -d</pre><pre># Stop all containers<br>docker compose down</pre><p>Docker Compose automatically:</p><ul><li>Builds images if they do not exist</li><li>Creates a shared network so containers can talk to each other</li><li>Starts containers in the correct order (database before backend)</li><li>Handles all port mappings and environment variables</li></ul><p>This is how most real development teams work locally — one<br>docker compose up and the entire application stack is running.</p><p><strong>Summary of all Docker files:</strong></p><p>FilePurposeDockerfileRecipe for building your image.dockerignoreFiles to exclude from the imagedocker-compose.ymlDefines and manages multiple containers</p><h3>Useful Docker Commands to Know</h3><p>Here are the commands you will use most often:</p><pre># Build an image<br>docker build -t my-app .</pre><pre># Run a container<br>docker run -p 3000:3000 my-app</pre><pre># Run in background (detached)<br>docker run -d -p 3000:3000 my-app</pre><pre># See all running containers<br>docker ps</pre><pre># See all containers including stopped ones<br>docker ps -a</pre><pre># See all images<br>docker images</pre><pre># Stop a running container<br>docker stop &lt;container-id&gt;</pre><pre># Remove a container<br>docker rm &lt;container-id&gt;</pre><pre># Remove an image<br>docker rmi my-app</pre><pre># See logs from a container<br>docker logs &lt;container-id&gt;</pre><pre># Open a terminal inside a running container<br>docker exec -it &lt;container-id&gt; sh</pre><p>The last command is extremely useful for debugging — it lets<br>you go inside a running container and look around, check files,<br>run commands, just like SSH-ing into a remote server.</p><h3>Why Developers Use Docker in Real Jobs</h3><p>Docker is not just a learning exercise. It is used by<br>essentially every serious technology company in the world.<br>Here is why:</p><h3>Consistent Environments</h3><p>Every developer on the team runs the exact same container.<br>No more “works on my machine” conversations. If it runs in<br>the container locally, it runs in the container on the server.</p><h3>Onboarding New Developers</h3><p>Without Docker — a new developer joins your team and spends<br>their first two days installing the right versions of Node.js,<br>PostgreSQL, Redis, and configuring everything correctly.</p><p>With Docker:</p><pre>git clone the-project<br>docker compose up</pre><p>That is it. Everything is running in minutes regardless of<br>what operating system they use.</p><h3>Identical Local and Production Environments</h3><p>The same container you test locally goes directly to production.<br>There is no “production-only bug” caused by environment<br>differences — what you test is exactly what runs live.</p><h3>Microservices Architecture</h3><p>Large companies like Netflix, Uber, and Amazon do not run<br>one giant application. They run hundreds of small independent<br>services — each one in its own container. Docker makes this<br>practical and manageable.</p><h3>Easy Scaling</h3><p>When traffic increases, you can spin up more containers quickly.<br>When traffic drops, you remove them. Each container is<br>lightweight and starts in seconds.</p><h3>A Simple Real World Example</h3><p>Let me show you the simplest possible Docker setup — a Node.js<br>app that responds with “Hello World”.</p><p><strong>app.js:</strong></p><pre>const http = require(&#39;http&#39;);</pre><pre>const server = http.createServer((req, res) =&gt; {<br>  res.writeHead(200, { &#39;Content-Type&#39;: &#39;text/plain&#39; });<br>  res.end(&#39;Hello World from inside a Docker container!\n&#39;);<br>});</pre><pre>server.listen(3000, () =&gt; {<br>  console.log(&#39;Server running on port 3000&#39;);<br>});</pre><p><strong>package.json:</strong></p><pre>{<br>  &quot;name&quot;: &quot;docker-hello-world&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;node app.js&quot;<br>  }<br>}</pre><p><strong>Dockerfile:</strong></p><pre>FROM node:20-alpine<br>WORKDIR /app<br>COPY package*.json ./<br>RUN npm install<br>COPY . .<br>EXPOSE 3000<br>CMD [&quot;node&quot;, &quot;app.js&quot;]</pre><p><strong>.dockerignore:</strong></p><p>node_modules<br>.env<br>*.log</p><p>Now run these commands:</p><pre># Build the image<br>docker build -t hello-world-app .</pre><pre># Run the container<br>docker run -p 3000:3000 hello-world-app</pre><p>Open your browser and go to http://localhost:3000 — you will<br>see &quot;Hello World from inside a Docker container!&quot;</p><p>That is your first containerized application running.</p><h3>What Comes After Docker — A Brief Look at Kubernetes</h3><p>Once you understand Docker you will naturally hear about<br><strong>Kubernetes</strong> (often abbreviated as K8s).</p><p>If Docker answers the question <em>“how do I package and run one<br>container?”</em>, Kubernetes answers the question <em>“how do I manage<br>hundreds or thousands of containers across many servers?”</em></p><p>Imagine you are Netflix:</p><ul><li>Millions of users watching videos simultaneously</li><li>Hundreds of microservices each in their own container</li><li>If one container crashes at 3 AM, it needs to restart automatically</li><li>During peak hours you need more containers, at 3 AM fewer</li></ul><p>Managing this manually is impossible. Kubernetes automates it:</p><ul><li><strong>Auto-scaling</strong> — adds more containers when traffic increases, removes them when traffic drops</li><li><strong>Self-healing</strong> — automatically restarts crashed containers</li><li><strong>Load balancing</strong> — distributes traffic evenly across containers</li><li><strong>Rolling updates</strong> — updates containers one by one with zero downtime</li></ul><p>Docker = managing ONE container<br>Kubernetes = managing THOUSANDS of containers across<br>MANY servers, automatically</p><p>You do not need Kubernetes for small projects. But knowing it<br>exists and understanding the relationship with Docker is<br>important context as you grow as a developer.</p><h3>Summary</h3><p>Here is everything we covered in one place:</p><p>ConceptSimple ExplanationThe ProblemCode behaves differently on different machinesContainerA sealed box with your app and everything it needsImageA frozen blueprint of your containerDockerfileThe recipe for building your image.dockerignoreFiles to exclude from the imagedocker-compose.ymlManages multiple containers togetherDocker HubPublic registry for sharing imagesKubernetesManages thousands of containers automatically</p><p>The journey from writing code to deploying it used to be full<br>of environment mismatches, configuration headaches, and “works<br>on my machine” frustrations. Docker changed that completely.</p><p>You write your Dockerfile once, build your image, and that<br>exact image runs identically on your laptop, your teammate’s<br>computer, and a server on the other side of the world.</p><p>That is the power of containerization.</p><p><em>If you found this helpful, drop a reaction or comment — I would<br>love to know which part clicked for you. And if something was<br>unclear, ask in the comments and I will explain it differently.</em></p><p><em>I recently used Docker to containerize my portfolio backend and<br>deploy it to Azure Container Apps — if you want to see a<br>practical step-by-step deployment guide, let me know in the<br>comments.</em></p><h3>docker #beginners #devops #webdevelopment</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5ac970c462a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>