{"id":92741,"date":"2024-01-09T21:01:51","date_gmt":"2024-01-10T02:31:51","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=92741"},"modified":"2024-01-09T21:01:51","modified_gmt":"2024-01-10T02:31:51","slug":"docker-networking-hands-on-labs","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/","title":{"rendered":"Understanding of\u00a0 Docker Networking using Hands-on Labs"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Docker networking constitutes a cluster of two or more devices capable of communication, either through physical or virtual means. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">By understanding docker networking, you can gain skills on how to <b><i>develop, deploy, and manage applications.<\/i><\/b><\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this article, we\u2019ll explain how <\/span><a href=\"https:\/\/www.whizlabs.com\/docker-certified-associate\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Docker network<\/span><\/a><span style=\"font-weight: 400;\"> functions and navigate Docker networks in real-time settings with our hands-on labs.<\/span><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ea7e02;color:#ea7e02\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ea7e02;color:#ea7e02\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#What_is_Docker\" >What is Docker?\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#What_is_Docker_Networking\" >What is Docker Networking?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#Docker_Networking_Types\" >Docker Networking Types<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#Basic_Docker_Networking_Commands\" >Basic Docker Networking Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#How_does_Docker_Networking_work\" >How does Docker Networking work?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#Docker_Networking_using_Hands-on_Labs\" >Docker Networking using Hands-on Labs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#FAQs\" >FAQs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.whizlabs.com\/blog\/docker-networking-hands-on-labs\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"What_is_Docker\"><\/span><span style=\"font-weight: 400;\">What is Docker?\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Docker is a platform designed to simplify the process of <\/span><b><i>developing, deploying, and managing applications<\/i><\/b><span style=\"font-weight: 400;\"> by utilizing <\/span><span style=\"font-weight: 400;\">containerization technology<\/span><span style=\"font-weight: 400;\">. It includes a networking unit for taking care of communication carried out between the container, docker host, and users.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To simplify, Docker allows you to package an application and all its dependencies into a single, lightweight unit called a container. These containers can run consistently across various environments, from a developer&#8217;s laptop to a production server, ensuring that an application behaves predictably and is easily scalable.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Docker employs a containerization platform to integrate software applications and their dependencies into recycled units named containers. Docker container can run on any host along with Docker or any equivalent container installed on run time.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">One key advantage of Docker is its ability to isolate applications and their dependencies, reducing conflicts between software components and improving system efficiency. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Containers are <em><strong>highly portable and can be quickly spun up or down<\/strong><\/em>, making it easier to scale resources up or down as needed. Containers are not full-fledged operating systems. They are more of thin operating systems meant for solving specific purposes only.\u00a0<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_Docker_Networking\"><\/span><span style=\"font-weight: 400;\">What is Docker Networking?<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Docker network, a virtual network established by Docker, facilitates interaction among Docker containers.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When two containers operate on the same host, they can communicate directly, eliminating the necessity to expose ports to the host machine. Docker offers a platform-agnostic approach for managing Docker hosts, accommodating various operating systems such as Windows, Linux, or a combination thereof<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Docker networking exhibits distinctions from networking in virtual machines (VMs) or physical machines in several aspects:<\/span><\/p>\n<p><b>Flexibility Differences<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Virtual machines offer greater flexibility in certain configurations, such as supporting Network Address Translation (NAT) and host networking. Docker predominantly utilizes a bridge network, and though it can accommodate host networking, this option is primarily available on Linux.<\/span><\/p>\n<p><b>Network Isolation Mechanism<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In Docker containers, network isolation is accomplished through a network namespace rather than a completely separate networking stack.<\/span><\/p>\n<p><b>Scale Considerations<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Docker allows the concurrent execution of numerous containers on a single-node host. Therefore, the host must be capable of supporting networking at this scale. In contrast, virtual machines typically encounter fewer network limitations since they usually run fewer processes per VM.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">These distinctions highlight how Docker networking introduces unique approaches and considerations compared to traditional virtual machine or physical machine networking. Understanding these differences is essential for effectively leveraging Docker&#8217;s networking capabilities.<\/span><\/p>\n<blockquote><p>Also Read: Free Questions on <a href=\"https:\/\/www.whizlabs.com\/blog\/docker-certified-associate-exam-questions\/https:\/\/www.whizlabs.com\/blog\/docker-certified-associate-exam-questions\/\" target=\"_blank\" rel=\"noopener\">Docker Certified Associate Exam<\/a><\/p><\/blockquote>\n<h3><span class=\"ez-toc-section\" id=\"Docker_Networking_Types\"><\/span><span style=\"font-weight: 400;\">Docker Networking Types<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Docker networking drivers help to configure the communications that take place between neighboring containers and external services. To achieve any network connection, containers need to be connected to the Docker network.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The communication routes information shared to the container depending upon its network connections.<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92776\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-scaled.webp\" alt=\"Docker Networking types\" width=\"2560\" height=\"1707\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-scaled.webp 2560w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-300x200.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-1024x683.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-768x512.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-1536x1024.webp 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-2048x1366.webp 2048w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-networking-types-150x100.webp 150w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Docker has five in-built networking drivers that deploy core networking functionalities such as:\u00a0<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Bridge:<\/b><span style=\"font-weight: 400;\"> It creates a software-based bridge between the host and container. Containers that are interlinked to the network communicate with each other but they do not connect with outside networks. <\/span>Each container in the network is allocated its IP address. As the network is bridged to your host, containers can communicate on both your local area network (LAN) and the internet. However, they won&#8217;t be visible as physical devices on your LAN.<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Host: <\/b><span style=\"font-weight: 400;\">Containers utilizing the host network mode share the host&#8217;s network stack without isolation. They do not receive separate IP addresses, and port bindings are directly exposed to the host&#8217;s network interface. Consequently, a container process listening on port 80 will bind to &lt;your_host_ip&gt;:80.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>overlay:<\/b><span style=\"font-weight: 400;\"> Overlay networks are expansive networks that extend across multiple Docker hosts. This network enables seamless communication between all containers running on any of the hosts, eliminating the need for operating system-level routing support.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>IPvlan:<\/b><span style=\"font-weight: 400;\"> Users have full control over both IPv4 and IPv6 addressing through the utilization of the IPvlan driver.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Macvlan:<\/b><span style=\"font-weight: 400;\"> The macvlan driver enables the assignment of MAC addresses to a container, providing users with this capability.<\/span><\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Basic_Docker_Networking_Commands\"><\/span><span style=\"font-weight: 400;\">Basic Docker Networking Commands<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Let\u2019s discuss some of the important networking commands that are widely used by developer teams.<\/span><\/p>\n<p><b>Check Docker Networks:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Use docker network ls to see a list of all networks in Docker.<\/span><\/p>\n<p><b>Link a Container to a Network<\/b><\/p>\n<p><span style=\"font-weight: 400;\">When a docker network connects a multi-host-network container, you can attach a running container to a network. You can also start a container and instantly connect it to various networks using Docker&#8217;s network feature.<\/span><\/p>\n<p><b>Assign a Specific IP to a Container<\/b><\/p>\n<p><span style=\"font-weight: 400;\">By running docker network connect &#8211;IP 10.10.36.122 multi-host-network container, you can set a custom IP, like 10.10.36.122, to a container.<\/span><\/p>\n<p><b>Set Shortcuts for a Container<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Use docker network connect &#8211;alias db &#8211;alias mysql multi-host-network container2 to create easy-to-remember names (aliases) for a container, making it simpler to access.<\/span><\/p>\n<p><b>Disconnect a Container<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Use docker network disconnect multi-host-network container1 to stop a container from being connected to a network.<\/span><\/p>\n<p><b>Delete a Specific Network:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Execute docker network rm network_name to get rid of a specific network from Docker.<\/span><\/p>\n<p><b>Delete Several Networks Together<\/b><\/p>\n<p><span style=\"font-weight: 400;\">If needed, you can remove multiple networks in one go by using a command like docker network rm 3695c422697f network_name.<\/span><\/p>\n<p><b>Clean Up Unused Networks<\/b><\/p>\n<p><span style=\"font-weight: 400;\">To clear out any networks not currently in use, just run docker network prune.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_does_Docker_Networking_work\"><\/span><span style=\"font-weight: 400;\">How does Docker Networking work?<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To gain a more comprehensive understanding, let&#8217;s explore how Docker Networking operates.\u00a0<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Docker Networking Workflow<\/span><\/h4>\n<p><b>Docker File builds the Docker Image<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The Docker File is responsible for constructing the Docker Image using the build command.<\/span><\/p>\n<p><b>Docker Image<\/b><\/p>\n<p><span style=\"font-weight: 400;\">This serves as a template with instructions and encompasses all the project&#8217;s code.<\/span><\/p>\n<p><b>Docker Container<\/b><\/p>\n<p><span style=\"font-weight: 400;\">An executable package that combines the application and its dependencies.<\/span><\/p>\n<p><b>Docker Hub<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Docker has its cloud-based registry, Docker Hub, where users store and distribute container images. <\/span><span style=\"font-weight: 400;\">Once the Docker Image is built, it can be uploaded to a registry or Docker Hub.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">By following this workflow, Docker enables the seamless creation, distribution, and execution of containerized applications. The Docker File, Image, and Container play distinct roles in this process, contributing to the efficiency and flexibility of Docker Networking.\u00a0\u00a0<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Docker_Networking_using_Hands-on_Labs\"><\/span><span style=\"font-weight: 400;\">Docker Networking using Hands-on Labs<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">In this laboratory session, you will delve into fundamental Docker networking concepts. The hands-on experience involves exploring examples that illustrate a range of basic networking principles. Through practical exercises, you will gain a deeper understanding of key Docker networking concepts.<\/span><\/p>\n<p>To use the docker network, you need to access the <a href=\"https:\/\/www.whizlabs.com\/labs\/understand-docker-networking\" target=\"_blank\" rel=\"noopener\">Whizlabs hands-on labs page<\/a>.<\/p>\n<p><em>Note: To access the lab&#8217;s page, you need a premium subscription.<\/em><\/p>\n<p>On the lab&#8217;s page, using the search bar, type docker network and select the labs related to docker networking. Go through the lab details before setting up the lab environment.\u00a0 It is a guided lab, so you have all the steps included in the lab details to build a docker network in the lab setup.<\/p>\n<h4><strong>Start the Lab Environment<\/strong><\/h4>\n<p>Click the &#8220;Start Lab&#8221; button placed in the right sidebar of the labs page. Now the lab environment has been set up successfully.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-92771\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-page.webp\" alt=\"lab page\" width=\"1109\" height=\"496\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-page.webp 1714w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-page-300x134.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-page-1024x458.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-page-768x343.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-page-1536x686.webp 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-page-150x67.webp 150w\" sizes=\"(max-width: 1109px) 100vw, 1109px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0Follow the lab steps to create the docker network in virtual settings:\u00a0<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-92774\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-steps.png\" alt=\"lab steps\" width=\"1109\" height=\"675\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-steps.png 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-steps-300x183.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-steps-1024x623.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-steps-768x468.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/lab-steps-150x91.png 150w\" sizes=\"(max-width: 1109px) 100vw, 1109px\" \/><\/p>\n<p><b>Step 1: Sign in to the AWS Management Console<\/b><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click on the Open Console button, and you will get redirected to AWS Console in a new browser tab.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">On the AWS sign-in page,<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Leave the Account ID as default. Never edit\/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Now copy your User Name and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign in button.<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Once Signed In to the AWS Management Console, Make the default AWS Region as US East (N. Virginia) us-east-1.<\/span><\/li>\n<\/ol>\n<p><b>Step 2 : SSH into EC2 Instance<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Select your EC2 instance(<\/span><b>whizlabs-docker<\/b><span style=\"font-weight: 400;\">) and click on the Connect button.<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92760\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ssh-1.webp\" alt=\"ssh\" width=\"678\" height=\"165\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ssh-1.webp 678w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ssh-1-300x73.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ssh-1-150x37.webp 150w\" sizes=\"(max-width: 678px) 100vw, 678px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Select the EC2 Instance Connect option and key in the Connect button. (Keep everything as default)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A new tab will open in the browser where you can run the Linux Commands.<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92761\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/linux.webp\" alt=\"linux\" width=\"654\" height=\"208\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/linux.webp 654w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/linux-300x95.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/linux-150x48.webp 150w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/p>\n<p><b>Step 3: Create a Docker Network\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Create a user-defined bridge network with the help of this command :<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92762\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-net.png\" alt=\"docker net\" width=\"1416\" height=\"50\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-net.png 1416w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-net-300x11.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-net-1024x36.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-net-768x27.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-net-150x5.png 150w\" sizes=\"(max-width: 1416px) 100vw, 1416px\" \/><\/p>\n<p><b>Step 4: Run Containers on &#8220;mynetwork&#8221;\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Run a container named <\/span><span style=\"font-weight: 400;\">container1<\/span><span style=\"font-weight: 400;\"> and connect it to <\/span><span style=\"font-weight: 400;\">mynetwork by key-in the below command:<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92764\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker.png\" alt=\"docker\" width=\"1416\" height=\"54\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker.png 1416w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-300x11.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-1024x39.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-768x29.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/docker-150x6.png 150w\" sizes=\"(max-width: 1416px) 100vw, 1416px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Run another container and name it as <\/span><span style=\"font-weight: 400;\">container2 and connect it to the same network :<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92765\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/container.png\" alt=\"container\" width=\"1410\" height=\"55\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/container.png 1410w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/container-300x12.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/container-1024x40.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/container-768x30.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/container-150x6.png 150w\" sizes=\"(max-width: 1410px) 100vw, 1410px\" \/><\/p>\n<p><b>Step 5: Inspect the Bridge Network\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Check the network settings for the <\/span><span style=\"font-weight: 400;\">mynetwork :<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92766\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/bridge.png\" alt=\"bridge\" width=\"1412\" height=\"53\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/bridge.png 1412w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/bridge-300x11.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/bridge-1024x38.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/bridge-768x29.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/bridge-150x6.png 150w\" sizes=\"(max-width: 1412px) 100vw, 1412px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Copy the IP address of the containers and save it somewhere :<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92767\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/sudo.png\" alt=\"sudo\" width=\"1055\" height=\"468\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/sudo.png 1055w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/sudo-300x133.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/sudo-1024x454.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/sudo-768x341.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/sudo-150x67.png 150w\" sizes=\"(max-width: 1055px) 100vw, 1055px\" \/><\/p>\n<p><b>Step 6: Test Communication in the containers\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s go inside of one container and ping the other one:\u00a0<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92768\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/exec.png\" alt=\"exec\" width=\"476\" height=\"139\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/exec.png 476w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/exec-300x88.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/exec-150x44.png 150w\" sizes=\"(max-width: 476px) 100vw, 476px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now we are in Container1 let&#8217;s try to ping :<\/span><\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-92769\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ping-c1.webp\" alt=\"ping c1\" width=\"844\" height=\"37\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ping-c1.webp 844w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ping-c1-300x13.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ping-c1-768x34.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/ping-c1-150x7.webp 150w\" sizes=\"(max-width: 844px) 100vw, 844px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Replace the &lt;IP_of_container2&gt; with the actual IP address that we saved in the previous task.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can also ping the container via the name of the container.<\/span><\/p>\n<h4><strong>End lab<\/strong><\/h4>\n<div class=\"center-column\">\n<div class=\"tabs-labs\">\n<div id=\"simple-tabpanel-1\" role=\"tabpanel\" aria-labelledby=\"simple-tab-1\">\n<div class=\"tab-content\">\n<div id=\"introduction\" class=\"description-section\">\n<div class=\"box\">\n<div class=\"descri-block\">\n<div class=\"react-scroll-to-bottom--css-ptels-1n7m0yu\">\n<div class=\"flex flex-col pb-9 text-sm\">\n<div class=\"w-full text-token-text-primary sm:AIPRM__conversation__response\" data-testid=\"conversation-turn-7\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group final-completion\">\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)] agent-turn\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"assistant\" data-message-id=\"15358251-677d-481c-943a-48113155ce48\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light AIPRM__conversation__response\">\n<p>After following the steps, click on &#8220;End Lab&#8221; on your Whizlabs lab console and wait for the process to finish.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-92870\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/endlab.webp\" alt=\"endlab\" width=\"1883\" height=\"359\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/endlab.webp 1883w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/endlab-300x57.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/endlab-1024x195.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/endlab-768x146.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/endlab-1536x293.webp 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/01\/endlab-150x29.webp 150w\" sizes=\"(max-width: 1883px) 100vw, 1883px\" \/><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"right-column\">\n<div class=\"lab-data-block\">\n<div class=\"head-block\">\n<div class=\"title\">\n<div class=\"icon-clock-block\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3><span class=\"ez-toc-section\" id=\"FAQs\"><\/span><span style=\"font-weight: 400;\">FAQs<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><b>How does Docker networking work?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Docker networking is built upon the principle of granting container<\/span><span style=\"font-weight: 400;\">s and their distinct network namespaces. This feature, rooted in the Linux kernel, ensures that each container operates within its secluded virtual network space. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Furthermore, as containers initiate, they establish virtual network interfaces on the host system. These interfaces empower containers to engage with networks beyond their designated namespaces, leveraging the host&#8217;s network capabilities for communication.<\/span><\/p>\n<p><b>List down the docker network commands.<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Here are some commands used in docker networking:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">docker network create<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">docker network connect<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">docker network ls<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">docker network rm<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">docker network disconnect<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">docker network inspect<\/span><\/li>\n<\/ul>\n<p><b>What is a container in\u00a0 Docker networking?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">A container network operates on a virtualization principle, akin to virtual machines (VMs), but with notable distinctions. Unlike VMs, which employ hardware virtualization, containerization is rooted in operating system virtualization.<\/span><\/p>\n<p><b>Is docker network prune safe?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Using the docker prune command is typically considered safe as it deletes unused containers, images, networks, and volumes. However, it&#8217;s important to note that this command will only eliminate resources that are not actively in use by any running container.<\/span><\/p>\n<p><b>What are the ways you can network containers in Docker?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In Docker, there are two primary methods to network containers:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Bridge Driver: This is a default network driver provided by Docker.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Overlay Driver: Another default network driver in Docker, designed for more advanced networking scenarios.<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><span style=\"font-weight: 400;\">Conclusion<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Hope this write-up covers everything about Docker and Docker Networking, some of its benefits, how Docker networking works, the Container network model, network drivers, and some basic Docker networking commands.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Utilizing the docker capabilities can enhance the communication that takes place between the networks.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you&#8217;d like to get a good understanding of the Docker tool, Whizlabs can solve your problem by offering<\/span><a href=\"https:\/\/www.whizlabs.com\/labs\/library\"><span style=\"font-weight: 400;\"> hands-on labs<\/span><\/a><span style=\"font-weight: 400;\"> to get in-depth knowledge about Docker.\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker networking constitutes a cluster of two or more devices capable of communication, either through physical or virtual means. By understanding docker networking, you can gain skills on how to develop, deploy, and manage applications. In this article, we\u2019ll explain how Docker network functions and navigate Docker networks in real-time settings with our hands-on labs. What is Docker?\u00a0 Docker is a platform designed to simplify the process of developing, deploying, and managing applications by utilizing containerization technology. It includes a networking unit for taking care of communication carried out between the container, docker host, and users.\u00a0 To simplify, Docker allows [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":92742,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[10],"tags":[5090,5091],"class_list":["post-92741","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-computing-certifications","tag-docker-networking-drivers","tag-docker-networking-types"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",1280,720,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-150x150.webp",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-300x169.webp",300,169,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-768x432.webp",768,432,true],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-1024x576.webp",1024,576,true],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",1280,720,false],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",1280,720,false],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",24,14,false],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",48,27,false],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",96,54,false],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",150,84,false],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs.webp",300,169,false],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-250x250.webp",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-640x720.webp",640,720,true],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2023\/12\/docker-networking-using-hands-on-labs-150x84.webp",150,84,true]},"uagb_author_info":{"display_name":"Karthikeyani Velusamy","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/karthikeyani-velusamy\/"},"uagb_comment_info":2,"uagb_excerpt":"Docker networking constitutes a cluster of two or more devices capable of communication, either through physical or virtual means. By understanding docker networking, you can gain skills on how to develop, deploy, and manage applications. In this article, we\u2019ll explain how Docker network functions and navigate Docker networks in real-time settings with our hands-on labs.&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/92741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=92741"}],"version-history":[{"count":15,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/92741\/revisions"}],"predecessor-version":[{"id":92929,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/92741\/revisions\/92929"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/92742"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=92741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=92741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=92741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}