<?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"><channel><title><![CDATA[Kashish Lakhara]]></title><description><![CDATA[Kashish Lakhara]]></description><link>https://techwithkashish.com</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 04:14:24 GMT</lastBuildDate><atom:link href="https://techwithkashish.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[What is DevOps?]]></title><description><![CDATA[Introduction
Do you know that DevOps can accomplish tasks in minutes which use to take hours or even days of work. So the companies can work on the business or the product. And maybe that's why the IT industry is adopting DevOps at such a rapid pace....]]></description><link>https://techwithkashish.com/what-is-devops</link><guid isPermaLink="true">https://techwithkashish.com/what-is-devops</guid><category><![CDATA[WeMakeDevs]]></category><category><![CDATA[Devops]]></category><category><![CDATA[introduction]]></category><category><![CDATA[SDLC]]></category><dc:creator><![CDATA[Kashish Lakhara]]></dc:creator><pubDate>Sun, 11 Dec 2022 19:43:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670700639149/L0Alebopa.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Do you know that DevOps can accomplish tasks in minutes which use to take hours or even days of work. So the companies can work on the business or the product. And maybe that's why the IT industry is adopting DevOps at such a rapid pace.</p>
<p><strong>But what exactly is DevOps?</strong></p>
<ul>
<li><p>Is it a software?</p>
</li>
<li><p>Is it a tool?</p>
</li>
<li><p>Is it a company?</p>
</li>
</ul>
<p><strong>So many explanations are out there:</strong>-</p>
<ul>
<li><p>Some say it's all about Automation/Scripting, is it?</p>
</li>
<li><p>DevOps is about culture, is it?</p>
</li>
<li><p>It's about tools, what tools?</p>
</li>
<li><p>Is DevOps cloud computing?</p>
</li>
</ul>
<p>To understand it first let's discuss Software Development Life Cycle (SDLC).</p>
<h2 id="heading-software-development-life-cycle-sdlc">Software Development Life Cycle (SDLC)</h2>
<p>Software development is a very well-defined and organized process. It consists of multiple phases.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670787959547/OTx5CuFKw.png" alt="sdlc.png" /></p>
<p><strong>1) Requirement gathering and analysis:</strong> In this phase, information is collected like product features, what users, how it will be used, user requirements, current market states, etc</p>
<p><strong>2)</strong> <strong>Planning</strong>: What do you want? It determines the cost and resources required for the implementation of the product and also the risks associated with it.</p>
<p><strong>3)</strong> <strong>Designing</strong>: In this phase, architects design the software based on the inputs from the previous phase. Architects produce design documents. These act like a roadmap for the developers.</p>
<p><strong>4)</strong> <strong>Development</strong>: This is where the developers write the software code based on the design.</p>
<p><strong>5)</strong> <strong>Testing (Quality assurance)</strong>: In this phase, the software is tested by software testers for any defects. Software is promoted to production only after fixing all the issues.</p>
<p><strong>6)</strong> <strong>Deployment</strong>: In this phase, the software is deployed to the production environment so users can start using the product. It's the responsibility of the system admin and the entire operations team to make sure the software is up and running all the time.</p>
<p><strong>7)</strong> <strong>Maintenance</strong>: It is a balance between regular changes and uptime.</p>
<p>This entire process is called Software Development Lifecycle (SDLC).</p>
<p>There are different models in SDLC:</p>
<ul>
<li><p>Waterfall</p>
</li>
<li><p>Agile</p>
</li>
<li><p>Spiral</p>
</li>
<li><p>Big Bang, etc</p>
</li>
</ul>
<p>You can refer to these models as paths or roadways to reach the same destination and choose a path based on different factors like cost, risk, and time taken to reach your destination.</p>
<p>Now let's discuss the <strong>Waterfall model</strong> and the <strong>Agile model</strong> in brief.</p>
<h3 id="heading-waterfall-model">Waterfall Model</h3>
<p>In the waterfall model, development happens in step by step manner. Each phase must be completed before the next phase begins. Requirement completes, then only planning begins. When everything is completed, all the features will be tested and then the maintenance phase starts.</p>
<p>It is very difficult to integrate new changes given by the client or change something that didn't work well in the planning. To do so, we have to almost restart the cycle which can be very expensive and time-consuming. This will lead to delays in delivering the software.</p>
<h3 id="heading-agile-model">Agile Model</h3>
<p>In the Agile model, instead of developing all the requirements for months, it is divided into smaller lists. Work on a list for 2 to 4 weeks and then move on to the next list. In other words, the entire process of building the application is divided into small sprints. Sprints generally last for 2 weeks (The team decides the length of the sprint). After every sprint, the client can give feedback so the team can make the changes quickly and effectively. The product is delivered faster as compared to the waterfall cycle.</p>
<p>Here, the product is tested only on the developer's environment and not on production. It's the operations team's job to deploy the application and make sure the application is up and running. But at times, the application fails in the production servers. This may be due to misconfigurations, or dependencies that didn't match, it can be anything. The operations team has no idea what's going on so they send the application back to the development team. Due to these failures and fixes, there is a delay in delivering the application.</p>
<h3 id="heading-dev-vs-ops">Dev vs Ops</h3>
<p>Dev and Ops are poles apart. Dev is agile, all about regular and quick changes. Ops is ITIL driven, and provides a stable environment for the application.</p>
<p>There is a big wall of confusion between these two teams. Developers toss their code over the wall and the Ops team's responsibility is to deploy the code on the servers. Developers complain about delays in deployments. The ops team complain about unclear instructions.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670788085769/Eb92Ocd6T.png" alt="wallDevOps.png" /></p>
<p>Due to frequent delays and errors, the consumers are not happy. And unhappy consumers cloud mean direct business loss.</p>
<p>This is where DevOps comes in.</p>
<h2 id="heading-what-is-devops">What is DevOps?</h2>
<p>DevOps is an evolution from the Agile model. The Agile model is great for developing and testing out solutions. It addresses the gap between clients and developers.</p>
<p>DevOps addresses the gap between the ops team and the dev team. So we are bringing the development team and the operations team together into a single team. Now they can work smoothly because they are integrated. The wall of confusion is brought down and both teams work together.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670788167005/6BGW1pFLd.png" alt="devopsGap.png" /></p>
<p>Automation training and instructions are given to every team across the board. Automation of each and every task in the code delivery processes like code build, code testing, software testing, infra changes, deployments, and everything that comes along the way.</p>
<h3 id="heading-devops-phases">DevOps phases</h3>
<p>The entire workflow in software development is divided into eight phases. This is quite similar to Agile as DevOps and agile are very closely related.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670788192747/8oen5Q8Me.png" alt="devopsCycle.png" /></p>
<ol>
<li><p><strong>Plan:-</strong> In this phase, the client and software development team discuss the project goals and accordingly create a plan.</p>
</li>
<li><p><strong>Code</strong>:- In this phase, the development team design and code the application based on the design. They use Version Control System (VCS) like <a target="_blank" href="https://git-scm.com/doc">Git</a> to maintain the code.</p>
</li>
<li><p><strong>Build</strong>:- In this phase, the application is built using tools like <a target="_blank" href="https://docs.gradle.org/current/userguide/userguide.html">Gradle</a> and <a target="_blank" href="https://maven.apache.org/guides/">Maven</a>. Gradle and Maven take code from different repositories and combine them to build the complete application.</p>
</li>
<li><p><strong>Testing</strong>:- Here, the application is tested to ensure the software quality. Automation testing tools like <a target="_blank" href="https://www.selenium.dev/">Selenium</a> and <a target="_blank" href="https://junit.org/junit5/docs/current/user-guide/">JUnit</a> are used in this phase.</p>
</li>
<li><p><strong>Integrate</strong>:- After completing testing, new features are integrated automatically into the codebase. Tools like  <a target="_blank" href="https://www.jenkins.io/doc/">Jenkins</a> are used in this phase.</p>
</li>
<li><p><strong>Deploy</strong>:- In this phase, the application is deployed from the development server to the production server.</p>
</li>
<li><p><strong>Operate</strong>:- Tools like <a target="_blank" href="https://docs.chef.io/">Chef</a> and <a target="_blank" href="https://docs.ansible.com/">Ansible</a> are used to perform operations like configuring servers and provisioning them with the required resources.</p>
</li>
<li><p><strong>Monitor</strong>:- In this phase, you monitor the entire environment. Monitoring allows us to identify the specific issues of specific releases and understand the impact on end-users.</p>
</li>
</ol>
<p><strong>Companies following DevOps</strong>:-</p>
<ul>
<li><p>Netflix</p>
</li>
<li><p>Adobe</p>
</li>
<li><p>Google</p>
</li>
<li><p>Microsoft</p>
</li>
<li><p>Nvidia</p>
</li>
<li><p>Cisco</p>
</li>
<li><p>Oracle</p>
</li>
<li><p>Sony</p>
</li>
<li><p>and many more...</p>
</li>
</ul>
<h3 id="heading-devops-advantages">DevOps Advantages</h3>
<ul>
<li><p>Continuous integration and continuous delivery ensure faster time to market.</p>
</li>
<li><p>Collaboration between developers and the operations team is improved.</p>
</li>
<li><p>Complexity of maintaining the application is reduced.</p>
</li>
<li><p>Time to create and deliver an application is reduced.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[The Evolution of Computing]]></title><description><![CDATA[Physical server

A physical server is wholly utilized by a single customer. You have to guess what your capacity is going to be and you're never going to 100% utilize that machine. You'll overpay for an underutilized server. You can't scale verticall...]]></description><link>https://techwithkashish.com/the-evolution-of-computing</link><guid isPermaLink="true">https://techwithkashish.com/the-evolution-of-computing</guid><category><![CDATA[BlogsWithCC]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[Virtual Machines]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[containers]]></category><dc:creator><![CDATA[Kashish Lakhara]]></dc:creator><pubDate>Sat, 08 Oct 2022 06:01:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1665208440023/8CbpTtlIu.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-physical-server">Physical server</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665208148796/_4DJz__tw.jpeg" alt="Physical.jpeg" class="image--center mx-auto" />
A physical server is wholly utilized by a single customer. You have to guess what your capacity is going to be and you're never going to 100% utilize that machine. You'll overpay for an underutilized server. You can't scale vertically, you can't resize it. You need a manual migration. Replacing a server is very difficult. You're limited by one host operating system. Running multiple apps is not a good practice for these machines because it may result in conflicts in resource sharing. Physical server provides more security, privacy, and full utility of underlying resources. If you have a virtual machine or anything above that, there is more responsibility on the cloud service provider to provide a secure machine.</p>
<h1 id="heading-virtual-machines">Virtual Machines</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665208177818/2Qu6mFgyU.jpeg" alt="VMs.jpeg" class="image--center mx-auto" />
You can run many virtual machines on one machine. With hypervisor you can run and manage multiple virtual machines. Here, a physical server will be shared by multiple customers. You have to pay for a fraction of a server. You'll overpay for underutilized part of the virtual machines because your app is not going to utilize 100% of memory, cpu, etc. If you run multiple apps on a single virtual machine, then it may result in conflicts in resource sharing. Its easier to export/import images for migration. Its easy to scale vertically or horizontally.  Virtual machines are the most common and popular offering for compute.</p>
<h1 id="heading-containers">Containers</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665208239064/-WWjun7FO.jpeg" alt="Containers.jpeg" class="image--center mx-auto" />
Here the idea is to run multiple containers on a virtual machine. Docker daemon manages the docker objects like containers, images, volumes, etc. You can maximize the capacity because you can easily add new containers and resize those containers use up the remaining space. The containers share the same underlying OS so containers are more efficient than multiple VMs. You can multiple apps without being limited to the same OS requirements and it will not cause conflicts during resource sharing.</p>
]]></content:encoded></item><item><title><![CDATA[Docker Networking]]></title><description><![CDATA[Docker containers are pure magic. They are very fast, and lightweight. But...How in the world networking work? When we add these containers to a host are they on their own network? Can we create more networks? Can we isolate them? Can we expose them?...]]></description><link>https://techwithkashish.com/docker-networking</link><guid isPermaLink="true">https://techwithkashish.com/docker-networking</guid><category><![CDATA[BlogsWithCC]]></category><category><![CDATA[docker-network]]></category><category><![CDATA[networking]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[Kashish Lakhara]]></dc:creator><pubDate>Sun, 28 Aug 2022 09:20:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/SInhLTQouEk/upload/v1661148615263/JUfIl7W0b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Docker containers are pure magic. They are very fast, and lightweight. But...How in the world networking work? When we add these containers to a host are they on their own network? Can we create more networks? Can we isolate them? Can we expose them? 
<br />
There are seven different types of networks which can be deployed with Docker containers. In this blog we will take a look at five types of network. 
<br />
To follow along with this blog you need to know what <a target="_blank" href="https://kashishlakhara.hashnode.dev/introduction-to-docker">docker</a> is and a host; A linux virtual machine where we can install Docker. Here I'll be using Ubuntu 22.04 LTS as OS.</p>
<p></p><h3> 1) Default network</h3>
Now lets jump into the terminal and look at out network interfaces. <p></p>
<pre><code>ip address <span class="hljs-keyword">show</span>
</code></pre><p>Output for me is </p>
<pre><code><span class="hljs-attribute">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue state UNKNOWN group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    <span class="hljs-attribute">inet</span> <span class="hljs-number">127.0.0.1</span>/<span class="hljs-number">8</span> scope host lo
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> ::<span class="hljs-number">1</span>/<span class="hljs-number">128</span> scope host 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">2</span>: wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/ether cc:<span class="hljs-number">6</span>b:<span class="hljs-number">1</span>e:<span class="hljs-number">5</span>a:<span class="hljs-number">7</span>b:<span class="hljs-number">93</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">192.168.52.189</span>/<span class="hljs-number">24</span> brd <span class="hljs-number">192.168.52.255</span> scope global dynamic noprefixroute wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">2019</span>sec preferred_lft <span class="hljs-number">2019</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:a<span class="hljs-number">19</span>f:f<span class="hljs-number">9</span>af:e<span class="hljs-number">1</span>a<span class="hljs-number">4</span>:d<span class="hljs-number">2</span>ef/<span class="hljs-number">64</span> scope global temporary dynamic 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3483</span>sec preferred_lft <span class="hljs-number">3483</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:beed:<span class="hljs-number">9</span>c<span class="hljs-number">45</span>:<span class="hljs-number">6</span>c<span class="hljs-number">2</span>d:<span class="hljs-number">11</span>ce/<span class="hljs-number">64</span> scope global dynamic mngtmpaddr noprefixroute 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3483</span>sec preferred_lft <span class="hljs-number">3483</span>sec
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">9</span>fc:<span class="hljs-number">90</span>cb:bcce:<span class="hljs-number">5587</span>/<span class="hljs-number">64</span> scope link noprefixroute 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">3</span>: docker<span class="hljs-number">0</span>: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state DOWN group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:<span class="hljs-number">30</span>:<span class="hljs-number">6</span>a:<span class="hljs-number">47</span>:<span class="hljs-number">21</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">172.17.0.1</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17.255.255</span> scope global docker<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
</code></pre><p>We have loop back interface and then main interface connecting us to our home network. But what is docker0? 
<br /><br />
Docker0 is a new virtual bridge interface. It is the default interface and network for the default bridge (the default network and docker).
<br />
Let's run this command, this will list our current docker networks.</p>
<pre><code><span class="hljs-attribute">sudo</span> docker network ls
</code></pre><p>The output is something like this</p>
<pre><code>NETWORK ID     <span class="hljs-type">NAME</span>      DRIVER    SCOPE
<span class="hljs-number">39e69177</span>fb39   bridge    bridge    <span class="hljs-keyword">local</span>
<span class="hljs-number">0</span>b4b4acc5aa4   host      host      <span class="hljs-keyword">local</span>
<span class="hljs-number">4717</span>db76952b   <span class="hljs-keyword">none</span>      <span class="hljs-keyword">null</span>      <span class="hljs-keyword">local</span>
</code></pre><p>We know "bridge" right here. But we don't know host and null. We will have a look at them soon. They are two of the seven networks in docker. 
<br />
Notice the section called <code>Driver</code>. Driver basically means network type. So our bridge network is named bridge and its type is also bridge. 
<br /><br />
<strong>Now what if we deploy some containers in our default network?</strong>
<br />
We will use this command </p>
<pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name container1 busybox
</code></pre><pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name container2 busybox
</code></pre><pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name container3 nginx
</code></pre><p>To make sure that the images are up we use this command </p>
<pre><code><span class="hljs-attribute">sudo</span> docker ps
</code></pre><p>Output:-</p>
<pre><code><span class="hljs-attribute">CONTAINER</span> ID   IMAGE     COMMAND                  CREATED              STATUS              PORTS     NAMES
<span class="hljs-attribute">9572a7554911</span>   nginx     <span class="hljs-string">"/docker-entrypoint.…"</span>   About a minute ago   Up About a minute   <span class="hljs-number">80</span>/tcp    container<span class="hljs-number">3</span>
<span class="hljs-attribute">edf3d34520ae</span>   busybox   <span class="hljs-string">"sh"</span>                     About a minute ago   Up About a minute             container<span class="hljs-number">2</span>
<span class="hljs-attribute">0b090aed1589</span>   busybox   <span class="hljs-string">"sh"</span>                     <span class="hljs-number">2</span> minutes ago        Up <span class="hljs-number">2</span> minutes                  container<span class="hljs-number">1</span>
</code></pre><p>Now, when we deployed our containers, did we specified anything about networking at all? No. We let it do it by default. So it got thrown into our default bridge network. When we deployed those containers in the default network, docker automatically created three virtual ethernet interfaces and connected it to the docker0 bridge. It kind of act like a switch. There is a virtual ethernet interface for each container. 
<br />
If we run <code>ip address show</code> again, it will show three new interfaces. </p>
<pre><code><span class="hljs-attribute">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue state UNKNOWN group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    <span class="hljs-attribute">inet</span> <span class="hljs-number">127.0.0.1</span>/<span class="hljs-number">8</span> scope host lo
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> ::<span class="hljs-number">1</span>/<span class="hljs-number">128</span> scope host 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">2</span>: wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/ether cc:<span class="hljs-number">6</span>b:<span class="hljs-number">1</span>e:<span class="hljs-number">5</span>a:<span class="hljs-number">7</span>b:<span class="hljs-number">93</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">192.168.52.189</span>/<span class="hljs-number">24</span> brd <span class="hljs-number">192.168.52.255</span> scope global dynamic noprefixroute wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">2232</span>sec preferred_lft <span class="hljs-number">2232</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:a<span class="hljs-number">19</span>f:f<span class="hljs-number">9</span>af:e<span class="hljs-number">1</span>a<span class="hljs-number">4</span>:d<span class="hljs-number">2</span>ef/<span class="hljs-number">64</span> scope global temporary dynamic 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3198</span>sec preferred_lft <span class="hljs-number">3198</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:beed:<span class="hljs-number">9</span>c<span class="hljs-number">45</span>:<span class="hljs-number">6</span>c<span class="hljs-number">2</span>d:<span class="hljs-number">11</span>ce/<span class="hljs-number">64</span> scope global dynamic mngtmpaddr noprefixroute 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3198</span>sec preferred_lft <span class="hljs-number">3198</span>sec
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">9</span>fc:<span class="hljs-number">90</span>cb:bcce:<span class="hljs-number">5587</span>/<span class="hljs-number">64</span> scope link noprefixroute 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">3</span>: docker<span class="hljs-number">0</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:<span class="hljs-number">30</span>:<span class="hljs-number">6</span>a:<span class="hljs-number">47</span>:<span class="hljs-number">21</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">172.17.0.1</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17.255.255</span> scope global docker<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">42</span>:<span class="hljs-number">30</span>ff:fe<span class="hljs-number">6</span>a:<span class="hljs-number">4721</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">5</span>: vethc<span class="hljs-number">88</span>ce<span class="hljs-number">7</span>d@if<span class="hljs-number">4</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">7</span>e:<span class="hljs-number">15</span>:d<span class="hljs-number">5</span>:da:<span class="hljs-number">9</span>e:<span class="hljs-number">7</span>c brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">0</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">7</span>c<span class="hljs-number">15</span>:d<span class="hljs-number">5</span>ff:feda:<span class="hljs-number">9</span>e<span class="hljs-number">7</span>c/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">7</span>: veth<span class="hljs-number">52546</span>bb@if<span class="hljs-number">6</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">82</span>:<span class="hljs-number">4</span>b:fc:<span class="hljs-number">10</span>:<span class="hljs-number">44</span>:<span class="hljs-number">97</span> brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">1</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">804</span>b:fcff:fe<span class="hljs-number">10</span>:<span class="hljs-number">4497</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">9</span>: vethb<span class="hljs-number">942</span>cb<span class="hljs-number">5</span>@if<span class="hljs-number">8</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether e<span class="hljs-number">2</span>:<span class="hljs-number">9</span>f:<span class="hljs-number">02</span>:<span class="hljs-number">22</span>:df:c<span class="hljs-number">4</span> brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">2</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::e<span class="hljs-number">09</span>f:<span class="hljs-number">2</span>ff:fe<span class="hljs-number">22</span>:dfc<span class="hljs-number">4</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
</code></pre><p>If we run this command, it will show there name and that they are connect to docker0</p>
<pre><code>bridge <span class="hljs-keyword">link</span>
</code></pre><p>Output:-</p>
<pre><code><span class="hljs-attribute">5</span>: vethc<span class="hljs-number">88</span>ce<span class="hljs-number">7</span>d@if<span class="hljs-number">4</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master docker<span class="hljs-number">0</span> state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span> 
<span class="hljs-attribute">7</span>: veth<span class="hljs-number">52546</span>bb@if<span class="hljs-number">6</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master docker<span class="hljs-number">0</span> state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span> 
<span class="hljs-attribute">9</span>: vethb<span class="hljs-number">942</span>cb<span class="hljs-number">5</span>@if<span class="hljs-number">8</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master docker<span class="hljs-number">0</span> state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span>
</code></pre><p>Bridge not only created virtual ethernet interfaces, but also allocated IP addresses. Let's dive into the bridge network with this command</p>
<pre><code><span class="hljs-attribute">sudo</span> docker inspect bridge
</code></pre><p>Output:-</p>
<pre><code>[
    {
        <span class="hljs-attr">"Name"</span>: <span class="hljs-string">"bridge"</span>,
        <span class="hljs-attr">"Id"</span>: <span class="hljs-string">"39e69177fb39d5f46405f0b2bb2eb30f78397756fa88a623efb36845c78929ba"</span>,
        <span class="hljs-attr">"Created"</span>: <span class="hljs-string">"2022-08-17T11:31:01.690732686+05:30"</span>,
        <span class="hljs-attr">"Scope"</span>: <span class="hljs-string">"local"</span>,
        <span class="hljs-attr">"Driver"</span>: <span class="hljs-string">"bridge"</span>,
        <span class="hljs-attr">"EnableIPv6"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"IPAM"</span>: {
            <span class="hljs-attr">"Driver"</span>: <span class="hljs-string">"default"</span>,
            <span class="hljs-attr">"Options"</span>: <span class="hljs-literal">null</span>,
            <span class="hljs-attr">"Config"</span>: [
                {
                    <span class="hljs-attr">"Subnet"</span>: <span class="hljs-string">"172.17.0.0/16"</span>,
                    <span class="hljs-attr">"Gateway"</span>: <span class="hljs-string">"172.17.0.1"</span>
                }
            ]
        },
        <span class="hljs-attr">"Internal"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"Attachable"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"Ingress"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"ConfigFrom"</span>: {
            <span class="hljs-attr">"Network"</span>: <span class="hljs-string">""</span>
        },
        <span class="hljs-attr">"ConfigOnly"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"Containers"</span>: {
            <span class="hljs-attr">"0b090aed15894615edc971e0d7fc717215507f8ef282710985e84425022ebc4f"</span>: {
                <span class="hljs-attr">"Name"</span>: <span class="hljs-string">"container1"</span>,
                <span class="hljs-attr">"EndpointID"</span>: <span class="hljs-string">"5c7e3f3751f513740f43982d263889042d08137fe0ea01fc86a71fc6e2545b40"</span>,
                <span class="hljs-attr">"MacAddress"</span>: <span class="hljs-string">"02:42:ac:11:00:02"</span>,
                <span class="hljs-attr">"IPv4Address"</span>: <span class="hljs-string">"172.17.0.2/16"</span>,
                <span class="hljs-attr">"IPv6Address"</span>: <span class="hljs-string">""</span>
            },
            <span class="hljs-attr">"9572a7554911d4ac23164d856484f48c39e6a81a3fb85cd5d9ef849303a7d832"</span>: {
                <span class="hljs-attr">"Name"</span>: <span class="hljs-string">"container3"</span>,
                <span class="hljs-attr">"EndpointID"</span>: <span class="hljs-string">"61c524a18b8803e077f0b3e765c23c8d5fc58524c352686802d17f2f80e39c5a"</span>,
                <span class="hljs-attr">"MacAddress"</span>: <span class="hljs-string">"02:42:ac:11:00:04"</span>,
                <span class="hljs-attr">"IPv4Address"</span>: <span class="hljs-string">"172.17.0.4/16"</span>,
                <span class="hljs-attr">"IPv6Address"</span>: <span class="hljs-string">""</span>
            },
            <span class="hljs-attr">"edf3d34520ae79ec97fcaa637708d1fd5f507954eeb33836cc35587ea01f70a1"</span>: {
                <span class="hljs-attr">"Name"</span>: <span class="hljs-string">"container2"</span>,
                <span class="hljs-attr">"EndpointID"</span>: <span class="hljs-string">"c1c66915c533d9dc95d2168c53deeb24e832a912e541539cbaadb9a55cb9544e"</span>,
                <span class="hljs-attr">"MacAddress"</span>: <span class="hljs-string">"02:42:ac:11:00:03"</span>,
                <span class="hljs-attr">"IPv4Address"</span>: <span class="hljs-string">"172.17.0.3/16"</span>,
                <span class="hljs-attr">"IPv6Address"</span>: <span class="hljs-string">""</span>
            }
        },
        <span class="hljs-attr">"Options"</span>: {
            <span class="hljs-attr">"com.docker.network.bridge.default_bridge"</span>: <span class="hljs-string">"true"</span>,
            <span class="hljs-attr">"com.docker.network.bridge.enable_icc"</span>: <span class="hljs-string">"true"</span>,
            <span class="hljs-attr">"com.docker.network.bridge.enable_ip_masquerade"</span>: <span class="hljs-string">"true"</span>,
            <span class="hljs-attr">"com.docker.network.bridge.host_binding_ipv4"</span>: <span class="hljs-string">"0.0.0.0"</span>,
            <span class="hljs-attr">"com.docker.network.bridge.name"</span>: <span class="hljs-string">"docker0"</span>,
            <span class="hljs-attr">"com.docker.network.driver.mtu"</span>: <span class="hljs-string">"1500"</span>
        },
        <span class="hljs-attr">"Labels"</span>: {}
    }
]
</code></pre><p>You can see that each container has its own ip address in that same docker0 network. It has DNS. And because the docker0 acts like a switch, the containers can talk to each other.
<br /><br />
We installed <code>nginx</code> which by default is a website and it will use port 80. Now, can we reach that website? In other words, can my computer can access that web server?
<br /> 
The answer is no. This is the limitation of the bridge network. If you want to access any of the services that your docker containers offer (website in this case), it won't work by default. You have to manually expose those ports. 
<br />
So let's expose port 80 to allow us to access and after that we have to redeploy container3.
First remove the container3 with the help of this command</p>
<pre><code>sudo docker <span class="hljs-keyword">stop</span> container3
</code></pre><p>Then redeploy it with but this time by doing port mapping, telling docker to expose the container's port 80 to the host port 80.</p>
<pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span>p <span class="hljs-number">80</span>:<span class="hljs-number">80</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name container3 nginx
</code></pre><p>Let's run this command to check what ports are being exposed</p>
<pre><code><span class="hljs-attribute">sudo</span> docker ps
</code></pre><p>Output:-</p>
<pre><code><span class="hljs-attribute">CONTAINER</span> ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                               NAMES
<span class="hljs-attribute">252c2de84f26</span>   nginx     <span class="hljs-string">"/docker-entrypoint.…"</span>   <span class="hljs-number">50</span> seconds ago   Up <span class="hljs-number">49</span> seconds   <span class="hljs-number">0.0.0.0:80</span>-&gt;<span class="hljs-number">80</span>/tcp, :::<span class="hljs-number">80</span>-&gt;<span class="hljs-number">80</span>/tcp   container<span class="hljs-number">3</span>
<span class="hljs-attribute">edf3d34520ae</span>   busybox   <span class="hljs-string">"sh"</span>                     <span class="hljs-number">53</span> minutes ago   Up <span class="hljs-number">53</span> minutes                                       container<span class="hljs-number">2</span>
<span class="hljs-attribute">0b090aed1589</span>   busybox   <span class="hljs-string">"sh"</span>                     <span class="hljs-number">54</span> minutes ago   Up <span class="hljs-number">54</span> minutes
</code></pre><p>Now we can see that now the website is running on our host machine.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1660748114075/H6kdZuxuY.png" alt="Screenshot from 2022-08-17 20-23-21.png" class="image--center mx-auto" />
It is not recommended to use default network but instead make you own network.</p>
<p></p><h3>2) User-Defined Bridge</h3>
This network is pretty much exactly like the default bridge. The name itself suggests that you're making it. You have to create your own network. 
<br />
Let's create our own network.
Run this command<p></p>
<pre><code><span class="hljs-attribute">sudo</span> docker network created tom
</code></pre><p>And that's it. Network created
<br />
If we check the list of docker networks by running command <code>sudo docker network ls</code>, it will show a network named <code>tom</code></p>
<pre><code>NETWORK ID     <span class="hljs-type">NAME</span>      DRIVER    SCOPE
<span class="hljs-number">39e69177</span>fb39   bridge    bridge    <span class="hljs-keyword">local</span>
<span class="hljs-number">0</span>b4b4acc5aa4   host      host      <span class="hljs-keyword">local</span>
<span class="hljs-number">4717</span>db76952b   <span class="hljs-keyword">none</span>      <span class="hljs-keyword">null</span>      <span class="hljs-keyword">local</span>
<span class="hljs-number">4</span>a17276f3a0f   tom       bridge    <span class="hljs-keyword">local</span>
</code></pre><p>If we run <code>ip address show</code>, we will see a new virtual bridge is being created with a new network. </p>
<pre><code><span class="hljs-attribute">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue state UNKNOWN group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    <span class="hljs-attribute">inet</span> <span class="hljs-number">127.0.0.1</span>/<span class="hljs-number">8</span> scope host lo
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> ::<span class="hljs-number">1</span>/<span class="hljs-number">128</span> scope host 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">2</span>: wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/ether cc:<span class="hljs-number">6</span>b:<span class="hljs-number">1</span>e:<span class="hljs-number">5</span>a:<span class="hljs-number">7</span>b:<span class="hljs-number">93</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">192.168.52.189</span>/<span class="hljs-number">24</span> brd <span class="hljs-number">192.168.52.255</span> scope global dynamic noprefixroute wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">2303</span>sec preferred_lft <span class="hljs-number">2303</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:a<span class="hljs-number">19</span>f:f<span class="hljs-number">9</span>af:e<span class="hljs-number">1</span>a<span class="hljs-number">4</span>:d<span class="hljs-number">2</span>ef/<span class="hljs-number">64</span> scope global temporary dynamic 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3430</span>sec preferred_lft <span class="hljs-number">3430</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:beed:<span class="hljs-number">9</span>c<span class="hljs-number">45</span>:<span class="hljs-number">6</span>c<span class="hljs-number">2</span>d:<span class="hljs-number">11</span>ce/<span class="hljs-number">64</span> scope global dynamic mngtmpaddr noprefixroute 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3430</span>sec preferred_lft <span class="hljs-number">3430</span>sec
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">9</span>fc:<span class="hljs-number">90</span>cb:bcce:<span class="hljs-number">5587</span>/<span class="hljs-number">64</span> scope link noprefixroute 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">3</span>: docker<span class="hljs-number">0</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:<span class="hljs-number">30</span>:<span class="hljs-number">6</span>a:<span class="hljs-number">47</span>:<span class="hljs-number">21</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">172.17.0.1</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17.255.255</span> scope global docker<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">42</span>:<span class="hljs-number">30</span>ff:fe<span class="hljs-number">6</span>a:<span class="hljs-number">4721</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">5</span>: vethc<span class="hljs-number">88</span>ce<span class="hljs-number">7</span>d@if<span class="hljs-number">4</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">7</span>e:<span class="hljs-number">15</span>:d<span class="hljs-number">5</span>:da:<span class="hljs-number">9</span>e:<span class="hljs-number">7</span>c brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">0</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">7</span>c<span class="hljs-number">15</span>:d<span class="hljs-number">5</span>ff:feda:<span class="hljs-number">9</span>e<span class="hljs-number">7</span>c/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">7</span>: veth<span class="hljs-number">52546</span>bb@if<span class="hljs-number">6</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">82</span>:<span class="hljs-number">4</span>b:fc:<span class="hljs-number">10</span>:<span class="hljs-number">44</span>:<span class="hljs-number">97</span> brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">1</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">804</span>b:fcff:fe<span class="hljs-number">10</span>:<span class="hljs-number">4497</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">11</span>: vethb<span class="hljs-number">9</span>e<span class="hljs-number">82</span>de@if<span class="hljs-number">10</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">96</span>:<span class="hljs-number">29</span>:<span class="hljs-number">18</span>:b<span class="hljs-number">8</span>:e<span class="hljs-number">1</span>:<span class="hljs-number">21</span> brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">2</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">9429</span>:<span class="hljs-number">18</span>ff:feb<span class="hljs-number">8</span>:e<span class="hljs-number">121</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">12</span>: br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state DOWN group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:de:<span class="hljs-number">2</span>b:a<span class="hljs-number">2</span>:<span class="hljs-number">38</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">172.18.0.1</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.18.255.255</span> scope global br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
</code></pre><p>Let's run a few containers inside this network</p>
<pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>network tom <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name loki busybox
</code></pre><pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>network tom <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name jerry busybox
</code></pre><p>Now if we do <code>ip address show</code>, we see we have virtual interfaces created.</p>
<pre><code><span class="hljs-attribute">1</span>: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu <span class="hljs-number">65536</span> qdisc noqueue state UNKNOWN group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/loopback <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> brd <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span>
    <span class="hljs-attribute">inet</span> <span class="hljs-number">127.0.0.1</span>/<span class="hljs-number">8</span> scope host lo
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> ::<span class="hljs-number">1</span>/<span class="hljs-number">128</span> scope host 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">2</span>: wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default qlen <span class="hljs-number">1000</span>
    <span class="hljs-attribute">link</span>/ether cc:<span class="hljs-number">6</span>b:<span class="hljs-number">1</span>e:<span class="hljs-number">5</span>a:<span class="hljs-number">7</span>b:<span class="hljs-number">93</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">192.168.52.189</span>/<span class="hljs-number">24</span> brd <span class="hljs-number">192.168.52.255</span> scope global dynamic noprefixroute wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">1841</span>sec preferred_lft <span class="hljs-number">1841</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:a<span class="hljs-number">19</span>f:f<span class="hljs-number">9</span>af:e<span class="hljs-number">1</span>a<span class="hljs-number">4</span>:d<span class="hljs-number">2</span>ef/<span class="hljs-number">64</span> scope global temporary dynamic 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3565</span>sec preferred_lft <span class="hljs-number">3565</span>sec
    <span class="hljs-attribute">inet6</span> <span class="hljs-number">2401</span>:<span class="hljs-number">4900</span>:<span class="hljs-number">50</span>a<span class="hljs-number">2</span>:be<span class="hljs-number">84</span>:beed:<span class="hljs-number">9</span>c<span class="hljs-number">45</span>:<span class="hljs-number">6</span>c<span class="hljs-number">2</span>d:<span class="hljs-number">11</span>ce/<span class="hljs-number">64</span> scope global dynamic mngtmpaddr noprefixroute 
       <span class="hljs-attribute">valid_lft</span> <span class="hljs-number">3565</span>sec preferred_lft <span class="hljs-number">3565</span>sec
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">9</span>fc:<span class="hljs-number">90</span>cb:bcce:<span class="hljs-number">5587</span>/<span class="hljs-number">64</span> scope link noprefixroute 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">3</span>: docker<span class="hljs-number">0</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:<span class="hljs-number">30</span>:<span class="hljs-number">6</span>a:<span class="hljs-number">47</span>:<span class="hljs-number">21</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">172.17.0.1</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.17.255.255</span> scope global docker<span class="hljs-number">0</span>
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">42</span>:<span class="hljs-number">30</span>ff:fe<span class="hljs-number">6</span>a:<span class="hljs-number">4721</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">5</span>: vethc<span class="hljs-number">88</span>ce<span class="hljs-number">7</span>d@if<span class="hljs-number">4</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">7</span>e:<span class="hljs-number">15</span>:d<span class="hljs-number">5</span>:da:<span class="hljs-number">9</span>e:<span class="hljs-number">7</span>c brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">0</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">7</span>c<span class="hljs-number">15</span>:d<span class="hljs-number">5</span>ff:feda:<span class="hljs-number">9</span>e<span class="hljs-number">7</span>c/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">7</span>: veth<span class="hljs-number">52546</span>bb@if<span class="hljs-number">6</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">82</span>:<span class="hljs-number">4</span>b:fc:<span class="hljs-number">10</span>:<span class="hljs-number">44</span>:<span class="hljs-number">97</span> brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">1</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">804</span>b:fcff:fe<span class="hljs-number">10</span>:<span class="hljs-number">4497</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">11</span>: vethb<span class="hljs-number">9</span>e<span class="hljs-number">82</span>de@if<span class="hljs-number">10</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master docker<span class="hljs-number">0</span> state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">96</span>:<span class="hljs-number">29</span>:<span class="hljs-number">18</span>:b<span class="hljs-number">8</span>:e<span class="hljs-number">1</span>:<span class="hljs-number">21</span> brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">2</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">9429</span>:<span class="hljs-number">18</span>ff:feb<span class="hljs-number">8</span>:e<span class="hljs-number">121</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">12</span>: br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">02</span>:<span class="hljs-number">42</span>:de:<span class="hljs-number">2</span>b:a<span class="hljs-number">2</span>:<span class="hljs-number">38</span> brd ff:ff:ff:ff:ff:ff
    <span class="hljs-attribute">inet</span> <span class="hljs-number">172.18.0.1</span>/<span class="hljs-number">16</span> brd <span class="hljs-number">172.18.255.255</span> scope global br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">42</span>:deff:fe<span class="hljs-number">2</span>b:a<span class="hljs-number">238</span>/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">14</span>: veth<span class="hljs-number">61</span>ad<span class="hljs-number">963</span>@if<span class="hljs-number">13</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">62</span>:ef:e<span class="hljs-number">3</span>:<span class="hljs-number">9</span>c:<span class="hljs-number">0</span>f:<span class="hljs-number">6</span>d brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">3</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">60</span>ef:e<span class="hljs-number">3</span>ff:fe<span class="hljs-number">9</span>c:f<span class="hljs-number">6</span>d/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
<span class="hljs-attribute">16</span>: veth<span class="hljs-number">133</span>cc<span class="hljs-number">0</span>f@if<span class="hljs-number">15</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> qdisc noqueue master br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f state UP group default 
    <span class="hljs-attribute">link</span>/ether <span class="hljs-number">3</span>e:be:<span class="hljs-number">1</span>f:<span class="hljs-number">7</span>a:b<span class="hljs-number">6</span>:<span class="hljs-number">7</span>c brd ff:ff:ff:ff:ff:ff link-netnsid <span class="hljs-number">4</span>
    <span class="hljs-attribute">inet6</span> fe<span class="hljs-number">80</span>::<span class="hljs-number">3</span>cbe:<span class="hljs-number">1</span>fff:fe<span class="hljs-number">7</span>a:b<span class="hljs-number">67</span>c/<span class="hljs-number">64</span> scope link 
       <span class="hljs-attribute">valid_lft</span> forever preferred_lft forever
</code></pre><p>And if we look at our <code>bridge link</code>, we see those new interfaces connected to that new virtual bridge.</p>
<pre><code><span class="hljs-attribute">5</span>: vethc<span class="hljs-number">88</span>ce<span class="hljs-number">7</span>d@if<span class="hljs-number">4</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master docker<span class="hljs-number">0</span> state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span> 
<span class="hljs-attribute">7</span>: veth<span class="hljs-number">52546</span>bb@if<span class="hljs-number">6</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master docker<span class="hljs-number">0</span> state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span> 
<span class="hljs-attribute">11</span>: vethb<span class="hljs-number">9</span>e<span class="hljs-number">82</span>de@if<span class="hljs-number">10</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master docker<span class="hljs-number">0</span> state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span> 
<span class="hljs-attribute">14</span>: veth<span class="hljs-number">61</span>ad<span class="hljs-number">963</span>@if<span class="hljs-number">13</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span> 
<span class="hljs-attribute">16</span>: veth<span class="hljs-number">133</span>cc<span class="hljs-number">0</span>f@if<span class="hljs-number">15</span>: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu <span class="hljs-number">1500</span> master br-<span class="hljs-number">4</span>a<span class="hljs-number">17276</span>f<span class="hljs-number">3</span>a<span class="hljs-number">0</span>f state forwarding priority <span class="hljs-number">32</span> cost <span class="hljs-number">2</span>
</code></pre><p>We can inspect that network using <code>sudo docker inspect tom</code> we get:</p>
<pre><code>[
    {
        <span class="hljs-attr">"Name"</span>: <span class="hljs-string">"tom"</span>,
        <span class="hljs-attr">"Id"</span>: <span class="hljs-string">"4a17276f3a0fbf55ca184c6eaf03016f88629c92a172647471429d3c3e9f51e3"</span>,
        <span class="hljs-attr">"Created"</span>: <span class="hljs-string">"2022-08-17T20:31:12.910872226+05:30"</span>,
        <span class="hljs-attr">"Scope"</span>: <span class="hljs-string">"local"</span>,
        <span class="hljs-attr">"Driver"</span>: <span class="hljs-string">"bridge"</span>,
        <span class="hljs-attr">"EnableIPv6"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"IPAM"</span>: {
            <span class="hljs-attr">"Driver"</span>: <span class="hljs-string">"default"</span>,
            <span class="hljs-attr">"Options"</span>: {},
            <span class="hljs-attr">"Config"</span>: [
                {
                    <span class="hljs-attr">"Subnet"</span>: <span class="hljs-string">"172.18.0.0/16"</span>,
                    <span class="hljs-attr">"Gateway"</span>: <span class="hljs-string">"172.18.0.1"</span>
                }
            ]
        },
        <span class="hljs-attr">"Internal"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"Attachable"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"Ingress"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"ConfigFrom"</span>: {
            <span class="hljs-attr">"Network"</span>: <span class="hljs-string">""</span>
        },
        <span class="hljs-attr">"ConfigOnly"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-attr">"Containers"</span>: {
            <span class="hljs-attr">"1e2dfd713e0b43a500b8064464b8d506ff03627f6d3e59ab2ad369bd7395a7e1"</span>: {
                <span class="hljs-attr">"Name"</span>: <span class="hljs-string">"loki"</span>,
                <span class="hljs-attr">"EndpointID"</span>: <span class="hljs-string">"75751a3622caac5f8e1b2c85b860a4bfd01b9c6c1f4a6dc49105ae7bd9ad2df5"</span>,
                <span class="hljs-attr">"MacAddress"</span>: <span class="hljs-string">"02:42:ac:12:00:02"</span>,
                <span class="hljs-attr">"IPv4Address"</span>: <span class="hljs-string">"172.18.0.2/16"</span>,
                <span class="hljs-attr">"IPv6Address"</span>: <span class="hljs-string">""</span>
            },
            <span class="hljs-attr">"d3b48638734122961e50a72ee82dde566906d6aafae7b112f21ff45aa5bc2af1"</span>: {
                <span class="hljs-attr">"Name"</span>: <span class="hljs-string">"jerry"</span>,
                <span class="hljs-attr">"EndpointID"</span>: <span class="hljs-string">"dab02cd5bc96fb657faacb0dbcf144ffef920c6284a97ff09ad724c8107102f7"</span>,
                <span class="hljs-attr">"MacAddress"</span>: <span class="hljs-string">"02:42:ac:12:00:03"</span>,
                <span class="hljs-attr">"IPv4Address"</span>: <span class="hljs-string">"172.18.0.3/16"</span>,
                <span class="hljs-attr">"IPv6Address"</span>: <span class="hljs-string">""</span>
            }
        },
        <span class="hljs-attr">"Options"</span>: {},
        <span class="hljs-attr">"Labels"</span>: {}
    }
]
</code></pre><p>We prefer this network over default network. Reason? Because of the isolation. This tom network is isolated/protected from the default network. They can't talk to each other. Network isolation is very important. You have to isolate your workloads and this is why docker recommends a user-defined bridge. </p>
<p></p><h3>3) Host network</h3>
We created container3 operating at port 80. Let's delete it and redeploy it on a host network. 
<br />
Stop container by this command: <code>sudo docker stop container3</code>, then run this command <br /><p></p>
<pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>network host <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name container3 nginx
</code></pre><p>When you deploy a container to the host network, it doesn't even really have its own network. It bums off the host. It shares its IP address and ports. This means that you don't have to expose any ports. Now nginx can run as a regular application on the host without port mapping, even though it is inside a container. 
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661668723902/lJw5qu3Co.png" alt="Screenshot from 2022-08-28 12-08-04.png" />
The downtime of this network is that there is no isolation. It's like right there next to the host.
<br /></p>
<p></p><h3>4) Macvlan network</h3>
What if we could erase all of these stuff, all the complications, all the docker networks and the virtual ethernet interfaces, the separate networks and simply connect the docker containers directly to our physical network. That's what macvlan about. It would be like their ethernet interfaces are connected directly to the switch in my house. They even get thier own mac addresses. Also they will have their own IP addresses on my home network. They are acting like virtual machines.
<br />
Let's create our macvlan network.<br /><p></p>
<pre><code>sudo docker network create <span class="hljs-operator">-</span>d macvlan <span class="hljs-operator">-</span><span class="hljs-operator">-</span>subnet <span class="hljs-number">192.168</span><span class="hljs-number">.239</span><span class="hljs-number">.0</span><span class="hljs-operator">/</span><span class="hljs-number">24</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>gateway <span class="hljs-number">192.168</span><span class="hljs-number">.239</span><span class="hljs-number">.12</span> <span class="hljs-operator">-</span>o parent<span class="hljs-operator">=</span>wlp2s0 macvlan
</code></pre><p>What is <code>parent=wlp2s0</code>? <br />
Here we have to tie our macvlan to our host network interface. The main interface of my ubuntu machine is <code>wlp2s0</code>. Check yours by doing <code>ip address show</code>. You must tie your macvlan network to a physical network. <br /><br />
Now lets do <code>sudo docker network ls</code></p>
<pre><code>NETWORK ID     <span class="hljs-type">NAME</span>      DRIVER    SCOPE
ed28e5c4ce86   bridge    bridge    <span class="hljs-keyword">local</span>
<span class="hljs-number">0</span>b4b4acc5aa4   host      host      <span class="hljs-keyword">local</span>
<span class="hljs-number">10</span>d74c0e21fe   macvlan   macvlan   <span class="hljs-keyword">local</span>
<span class="hljs-number">4717</span>db76952b   <span class="hljs-keyword">none</span>      <span class="hljs-keyword">null</span>      <span class="hljs-keyword">local</span>
<span class="hljs-number">4</span>a17276f3a0f   tom       bridge    <span class="hljs-keyword">local</span>
</code></pre><p>Here we go. We can see a new network named <code>macvlan</code> of type <code>macvlan</code> is created. <br />
Now let's run some containers inside macvlan network.</p>
<pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>network macvlan <span class="hljs-operator">-</span><span class="hljs-operator">-</span>ip <span class="hljs-number">192.168</span><span class="hljs-number">.239</span><span class="hljs-number">.23</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name jerry busybox
</code></pre><p>Now jerry is connected to macvlan network like a regular virtual machine. <br />
In macvlan network, all the docker containers get their own mac addresses. Now where that becomes an issue is your network may not be able to have multiple mac addresses on one switch port. The cable connection is sharing a port with the host. They're all connected to the same port which will see multiple mac addresses and a lot of times port can't handle that. It might have port security, which says you can have one or maybe two mac addresses on one port and that breaks things. You will often see this called promiscuous mode. If you want to try this, you will need that enabled. 
<br /><br />
Let's first try with the host. We have to actually enable promiscuous mode on its network interface.<br />
Run this command:</p>
<pre><code><span class="hljs-attribute">sudo</span> ip link set wlp<span class="hljs-number">2</span>s<span class="hljs-number">0</span> promisc <span class="hljs-literal">on</span>
</code></pre><p>Now lets see if it worked. Run this command and <code>ping 192.168.239.23</code></p>
<pre><code>sudo docker <span class="hljs-keyword">exec</span> -it jerry sh
</code></pre><p>The macvlan has all the benefits of a bridge network, except its directly connected to your home network. If we deploy a web server in a macvlan, we don't have to expose any ports.
<br /><br />
Macvlan has its downsides. That whole mac address thing happened to have promiscuous mode, which you may have no control over and the IP address thing, no dhcp. You would expect that if you connect your device directly to your home network, it will get an IP address from your router whatever that's offering dhcp. But no. If you don't specify an IP address when you deploy your container, docker will choose one for you. Docker will use its own dhcp and assign like <code>192.168.238.4</code> or <code>192.168.238.5</code> or anything which could create a litter conflict because you got two dhcp servers in your network. So in that scenario, just specify your IP address with every container.
<br /><br />
Now let's talk about our next network.</p>
<p></p><h3>5) Ipvlan network</h3>
This one solves the problem with <code>macvlans</code>, that promiscuous stuff. Ipvlan network has two different modes, L2 and L3. We will focus on L2 because it's pretty much same as macvlan with one difference and it solves our problem.
<br />
We have jerry and loki in a macvlan and they are assigned their own mac address. But it messes with our switches and the promiscuous stuff. Ipvlan allow the host to share its mac address with the containers. So the mac address of jerry and loki will match exactly to the host, but they will still have IP addresses on our network. This seems to resolve all issues. 
<br /><br />
Let's create ipvlan network<p></p>
<pre><code>sudo docker network create <span class="hljs-operator">-</span>d ipvlan <span class="hljs-operator">-</span><span class="hljs-operator">-</span>subnet <span class="hljs-number">192.168</span><span class="hljs-number">.239</span><span class="hljs-number">.0</span><span class="hljs-operator">/</span><span class="hljs-number">24</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>gateway <span class="hljs-number">192.168</span><span class="hljs-number">.239</span><span class="hljs-number">.12</span> <span class="hljs-operator">-</span>o parent<span class="hljs-operator">=</span>wlp2s0 ipvlan
</code></pre><p>Now add new container:</p>
<pre><code>sudo docker run <span class="hljs-operator">-</span>itd <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rm <span class="hljs-operator">-</span><span class="hljs-operator">-</span>network ipvlan <span class="hljs-operator">-</span><span class="hljs-operator">-</span>ip <span class="hljs-number">192.168</span><span class="hljs-number">.239</span><span class="hljs-number">.20</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name kashish busybox
</code></pre>]]></content:encoded></item><item><title><![CDATA[Containerizing Nginx server]]></title><description><![CDATA[In this docker tutorial, I'll demonstrate how to containerize Nginx application. If you are a beginner, then you will find this tutorial very helpful. Even if you are not familiar with what Nginx is, it will be easy for you to follow this tutorial.
P...]]></description><link>https://techwithkashish.com/containerizing-nginx-server</link><guid isPermaLink="true">https://techwithkashish.com/containerizing-nginx-server</guid><category><![CDATA[Docker]]></category><category><![CDATA[docker images]]></category><category><![CDATA[containers]]></category><category><![CDATA[Container Apps]]></category><category><![CDATA[BlogsWithCC]]></category><dc:creator><![CDATA[Kashish Lakhara]]></dc:creator><pubDate>Sat, 06 Aug 2022 15:23:35 GMT</pubDate><content:encoded><![CDATA[<p>In this docker tutorial, I'll demonstrate how to containerize Nginx application. If you are a beginner, then you will find this tutorial very helpful. Even if you are not familiar with what Nginx is, it will be easy for you to follow this tutorial.</p>
<p></p><h2>Prerequisites</h2>
1) To know the basics of docker you can check out my previous blog <a target="_blank" href="https://kashishlakhara.hashnode.dev/introduction-to-docker">here</a>
<br />
2) <strong>Docker Installation</strong> 
<br />
<a target="_blank" href="https://docs.docker.com/desktop/install/windows-install/">For windows</a>
<br />
<a target="_blank" href="https://docs.docker.com/desktop/install/mac-install/">For Mac</a>
<br />
<a target="_blank" href="https://docs.docker.com/engine/install/ubuntu/">For ubuntu</a>
<br /> <br />
To check if docker is installed successfully, run <code>docker run -it hello-world</code>. If it runs, then docker is successfully installed on your machine. You can check its version by <code>docker -v</code>. <p></p>
<p></p><h2>Let's build container!</h2>
In this Docker tutorial, we will containerize Nginx application.
<br />
Create a dockerfile (dockerfiles are the files with no extension).
<br /><br />
<strong>Some Dockerfile commands:-</strong>
<br />
Dockerfile is just a series of commands.
<br /><br />
<strong>FROM</strong> It defines the base image to start the build process.
<br /><br />
<strong>RUN</strong> If you want to run a particular image or a particular command, them you use this command.
<br /><br />
<strong>CMD</strong> Similar to run, can be used for executing a specific command. It is not executed during build, but when a container is instantiated using the image being built.
<br /><br />
<strong>ENTRYPOINT</strong> Suggests that when you've finished building your docker image, then the command which is specified with the entrypoint that will executed first when you run the docker container of that particular image.
<br /><br />
<strong>ADD</strong> ADD or COPY command are the commands which can be interchangeably because the add command is used to copy whatever files are there in one directory to another directory.
<br /><br />
<strong>ENV</strong> If an application needs a particular environment variable, then we can specify to our docker container that this application needs certain environment variables and this environment variable is present over here.
<br /><br />
<strong>WORKDIR</strong> Used to set where the command defined with CMD is to be executed.
<br /><br />
<strong>EXPOSE</strong> You can specify a port number where you want your application to run inside the container.
<br /><br />
<strong>MAINTAINER</strong> If you want to tag your name along with the image which you are building, then you use this command.
<br /><br />
<strong>USER</strong> If you want a particular user to execute or to run a container, then you can use this user command and specify that user.
<br /><br />
<strong>VOLUME</strong> If you have multiple containers which are hosting the same application, then you might want them all to use the same path. So this is the path where it can be present.
<br /><br /><p></p>
<p><strong>Dockerfile:-</strong></p>
<pre><code>FROM ubuntu:<span class="hljs-number">22.04</span>
MAINTAINER Kashish

RUN apt<span class="hljs-operator">-</span>get update <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> apt<span class="hljs-operator">-</span>get install <span class="hljs-operator">-</span>y nginx
ADD index.html <span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>share<span class="hljs-operator">/</span>nginx<span class="hljs-operator">/</span>html<span class="hljs-operator">/</span>index.html

CMD [<span class="hljs-string">"nginx"</span>, <span class="hljs-string">"-g"</span>, <span class="hljs-string">"daemon off;"</span>]
EXPOSE <span class="hljs-number">80</span>
</code></pre><p><code>FROM ubuntu:22.04</code> means that we are using ubuntu as a base image
<br /><br />
<code>MAINTAINER Kashish</code> just tags my name
<br /><br />
<code>apt-get update</code> will update apt-get repositories
<br />
<code>apt-get install -y nginx</code> will install nginx service 
<br /><br />
Then we have to add <code>index.html</code> file to <code>/usr/share/nginx/html/index.html</code>, i.e, copy html file inside the container.
<br /><br />
<code>CMD ["nginx", "-g", "daemon off;"]</code> will start nginx service. Nginx uses the daemon off directive to run in the foreground. If daemon on, then application would be running in background. With daemon off, we can see the UI.
<br /><br />
<code>EXPOSE 80</code> means our nginx service will be hosted on port 80.
<br />
<strong>Note:</strong> This runs within the container. If you want to access it on your host machine then you have to do port mapping while starting this container.</p>
<p>Create a simple html file.
<br />
<strong>HTML file:-</strong></p>
<pre><code><span class="hljs-operator">&lt;</span>html<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>head<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>title<span class="hljs-operator">&gt;</span> Nginx Image <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>title<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>head<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>body<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>h1<span class="hljs-operator">&gt;</span> Hello World<span class="hljs-operator">!</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>h1<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>body<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>html<span class="hljs-operator">&gt;</span>
</code></pre><p></p><h2>Build an image and run the container</h2>
To build the docker image out of dockerfile, move to the directory where the dockerfile is saved and run <code>sudo docker build -t nginximage .</code> Wait for all the steps to be executed. This will be our custom ubuntu image.
<br /><br />
We can now use this image to run the container.
<br />
To spin up a container out of this docker image run the following command. 
<br /><p></p>
<pre><code>sudo docker run <span class="hljs-operator">-</span>p <span class="hljs-number">80</span>:<span class="hljs-number">80</span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span>name<span class="hljs-operator">=</span>container nginximage
</code></pre><p>Now your container would be active. Let's go to localhost and check if that's working.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659797449298/bn2BlT-ei.png" alt="image.png" />
To stop the container, run the command <code>sudo docker ps</code>. It will show your container id. Copy that and run <code>sudo docker stop (container_id)</code> </p>
<p>That's all for this tutorial. We you have any questions feel free to ask them in comment section. And as always your feedbacks are appreciated!</p>
]]></content:encoded></item><item><title><![CDATA[Introduction to Docker]]></title><description><![CDATA[Problems before Docker:- 
A developer develops and runs an application. Now that application works in developer’s laptop but not in testing or production. This problem is arised due to difference in computing environment between developer, test and p...]]></description><link>https://techwithkashish.com/introduction-to-docker</link><guid isPermaLink="true">https://techwithkashish.com/introduction-to-docker</guid><category><![CDATA[Docker]]></category><category><![CDATA[docker images]]></category><category><![CDATA[Docker compose]]></category><category><![CDATA[BlogsWithCC]]></category><dc:creator><![CDATA[Kashish Lakhara]]></dc:creator><pubDate>Wed, 03 Aug 2022 03:50:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/HSACbYjZsqQ/upload/v1659497726931/JuE6_aSqg.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Problems before Docker:-</strong> <br />
A developer develops and runs an application. Now that application works in developer’s laptop but not in testing or production. This problem is arised due to difference in computing environment between developer, test and production team. In development environment there can be a software that is upgraded and in testing and production environment, the older version of software might be present.
<br />
<br />
<strong>What is Docker?</strong>
<br />
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Docker containers are lightweight alternatives to Virtual Machines and it uses the host OS. You don't have to pre-allocate any RAM in containers.</p>
<p>Dockerfile builds a docker image and that image contains all the project's code. You can run that image to create as many docker containers as you want. Then this image can be uploaded on DockerHub, from DockerHub anyone can pull the image and build a container.
<br /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659497912860/a0D3rPTvG.png" alt="image.png" class="image--center mx-auto" /></p>
<p>Docker images are huge in size and requires a lot of network bandwidth. So in order to save that network bandwidth, we use Jenkins server or any continuous integration server to build an environment that contains all the dependencies for a particular application or a microservice and that build environment is deployed onto various teams like testing, staging and production.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659497983257/hV8InbP33.png" alt="image.png" class="image--center mx-auto" />
Create complex requirements for a microservice within an easy-to-write Dockerfile. Then push the code to the Git repository. CI server pull it down and build the exact environment that will be used in production to run the test suite without needing to configure the CI server at all. Deploy it out to a staging environment for testers. Roll exactly what you had in development, testing, and staging into production.</p>
<p><strong>What is Docker registry?</strong>
<br />
Docker registry is a storage component for Docker images. We can store the images in either public or private repositories. DockerHub is famous public cloud repository.
<br />
<strong>Why use Docker Registries?</strong>
<br />
You can control where your images are being stored. Integrate image storage with your in-house development workflow.
<br />
<br />
<strong>What are Docker images?</strong>
<br />
Docker images are read only template that can be used to create containers out of it. These docker images contains all the dependencies for a particular application or any microservice. You can create your own image and upload that onto the DockerHub and at the same time you can also pull the images which are available in the public repositories.
<br />
<br />
<strong>What are Docker containers?</strong>
<br />
Docker containers are nothing but the runtime instances of docker images. It contains everthing that is required to run an application or any microservice. It is also possible that more than one image is required to create a container. Docker containers can be referred to as isolated application platform built from one or more docker images.
<br />
<br />
<strong>Docker compose</strong>
<br />
Suppose you have multiple applications on various containers and all those containers are linked together. So you don’t want to actually execute each of those containers one by one but want to run those containers at once with a single command. So here docker compose comes into picture. </p>
<p>Docker compose makes it easier to configure and run applications made up of multiple containers.
For example, you define four containers in one YAML file and then run those four containers with a single command. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659498271987/f1_hB5Gqr.png" alt="image.png" class="image--center mx-auto" /></p>
<p>That's it for this one. 
<br />
Thanks for reading!
<br />
Any feedbacks are welcome!!</p>
]]></content:encoded></item><item><title><![CDATA[What is a Protocol?]]></title><description><![CDATA[Human Analogy

It is probably easiest to understand the notion of a computer network protocol by first considering some human analogies.

Consider what you do when you want to ask someone for the time of day. Human protocol dictates that one first of...]]></description><link>https://techwithkashish.com/what-is-a-protocol</link><guid isPermaLink="true">https://techwithkashish.com/what-is-a-protocol</guid><category><![CDATA[protocols]]></category><category><![CDATA[networking]]></category><category><![CDATA[#computernetwork ]]></category><dc:creator><![CDATA[Kashish Lakhara]]></dc:creator><pubDate>Tue, 26 Jul 2022 16:05:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658849046795/gTLwnoLSg.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Human Analogy</strong>
<br />
It is probably easiest to understand the notion of a computer network protocol by first considering some human analogies.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658850931342/_JNDOa4oX.png" alt="image.png" class="image--center mx-auto" /></p>
<p>Consider what you do when you want to ask someone for the time of day. Human protocol dictates that one first offer a greeting to initiate communication with someone else.. The typical response to a “Hi” is a returned “Hi” message. Implicitly, one then takes a cordial “Hi” response as an indication that one can proceed and ask for the time of day. </p>
<p>A different response to the initial “Hi” (such as “Don’t bother me”) might indicate an unwillingness or inability to communicate. In this case, the human protocol would be not to ask for the time of day. Sometimes one gets no response at all to a message, in such case one typically gives up asking that person for time.</p>
<p>Clearly, transmitted and received messages, and actions taken when these messages are sent or received or other events occur, play a central role in a human protocol. If people run different protocols (For example, if one person has manners but the other does not, or if one understands the concept of time and other does not) the protocols do not interoperate and no useful work can be accomplished. The same is true in networking – it takes two or more communicating entities running the same protocol in order to accomplish a task.</p>
<p><strong>Network Protocols</strong></p>
<p>A network protocol is similar to a human protocol, except that the entities exchanging messages and taking actions are hardware or software components of some device (like laptop, tablet, smartphone, router or other network-capable device). All the activity in the Internet that involves two or more communicating remote entities is governed by a protocol.</p>
<p>As an example of a computer network protocol with which you are probably familiar, consider what happens when you type the URL of a Web page into your Web browser. The scenario is illustrated in the right half of the figure. </p>
<p>First your machine will send a connection request message to the Web server and wait for a reply. The Web server will eventually receive your connection request message and return a connection reply message. Knowing that it is OK to request the Web document, your machine then sends the name of the Web page it wants to fetch from that Web server in a GET message. Finally, the web server returns the web page (file) to your machine.</p>
<p><strong>Conclusion</strong></p>
<p>Given the human and networking examples above, the exchange of messages and the actions taken when these messages are sent and received are the key defining elements of a protocol: 
<br />
<em>A protocol defines the format and the order of messages exchanged between two or more communicating entities, as well as the actions taken on the transmission and/or receipt of a message or other event.</em></p>
<p>The Internet, and computer networks in general, make extensive use of protocols. Different protocols are used to accomplish different tasks. Some protocols are simple and straightforward, while others are complex and intellectually deep. </p>
]]></content:encoded></item></channel></rss>