|
|
| Line 1: |
Line 1: |
| − | <div style="margin-left:1.27cm;margin-right:0cm;"></div>
| + | |
| | {| border="1" | | {| border="1" |
| | |- | | |- |
| Line 5: |
Line 5: |
| | || '''Narration''' | | || '''Narration''' |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''Title Slide''' | | '''Title Slide''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Hello and welcome to the Spoken Tutorial on “'''Docker Networking”.''' | + | || Hello and welcome to the Spoken Tutorial on “'''Docker Networking”.''' |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''Learning Objectives''' | | '''Learning Objectives''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | In this tutorial, we will learn about: | + | || In this tutorial, we will learn about: |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Fundamentals of Docker networking.</div> | + | * Fundamentals of Docker networking. |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Connecting containers and establishing communication links.</div> | + | * Connecting containers and establishing communication links. |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Configuring port exposure and service exposure.</div> | + | * Configuring port exposure and service exposure. |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Deleting docker network</div> | + | * Deleting docker network |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''System Requirements''' | | '''System Requirements''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | To record this tutorial, I am using | + | || To record this tutorial, I am using |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">'''Ubuntu Linux '''OS version '''22.04'''</div> | + | * '''Ubuntu Linux '''OS version '''22.04''' |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">'''Docker version 27.0.2'''</div> | + | * '''Docker version 27.0.2''' |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''Prerequisite''' | | '''Prerequisite''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | To follow this tutorial, | + | || To follow this tutorial, |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">You must have basic knowledge of using Linux terminal</div> | + | * You must have basic knowledge of using Linux terminal |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">For pre-requisite Linux tutorials, please visit this website</div> | + | * For pre-requisite Linux tutorials, please visit this website |
| | | | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''Fundamentals of Docker networking''' | | '''Fundamentals of Docker networking''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Docker networking involves various components and configurations</div> | + | * Docker networking involves various components and configurations |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Docker uses network namespaces to isolate network resources.</div> | + | * Docker uses network namespaces to isolate network resources. |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Docker facilitates this through network links and service discovery mechanisms</div> | + | * Docker facilitates this through network links and service discovery mechanisms |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''Types of Docker networks''' | | '''Types of Docker networks''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || |
| | | | |
| − | {| style="border-spacing:0;width:7.761cm;" | + | {| border=1 |
| − | |- style="border:none;padding:0.176cm;" | + | |- |
| | || Docker provides several types of networks: | | || Docker provides several types of networks: |
| | |- | | |- |
| | |} | | |} |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">'''Bridge Network''':It is the default network type</div> | + | * '''Bridge Network''':It is the default network type |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">'''Host Network''': The Containers share the host’s network stack</div> | + | * '''Host Network''': The Containers share the host’s network stack |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">'''Overlay Network''': It enables communication between containers</div> | + | * '''Overlay Network''': It enables communication between containers |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">'''Macvlan Network''': It assigns a MAC address to each container, making it appear as a physical device</div> | + | * '''Macvlan Network''': It assigns a MAC address to each container, making it appear as a physical device |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">'''None Network:''' It disables networking for the container</div> | + | * '''None Network:''' It disables networking for the container |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || In this tutorial we will demonstrate how to use '''Bridge Network.''' |
| − | | + | |
| − | In this tutorial we will demonstrate how to use '''Bridge Network.''' | + | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Open Linux terminal | + | || Open Linux terminal |
| | | | |
| | '''Create a Docker network''' | | '''Create a Docker network''' |
| Line 69: |
Line 67: |
| | | | |
| | Highlight '''network id''' | | Highlight '''network id''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || Open your''' terminal'''. |
| − | Open your''' terminal'''. | + | |
| | | | |
| | Let us first create a docker network. | | Let us first create a docker network. |
| Line 83: |
Line 80: |
| | | | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Type command | + | || Type command |
| | | | |
| | '''docker network ls''' | | '''docker network ls''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | To view all the docker network, type the command | + | || To view all the docker network, type the command |
| | | | |
| | '''docker network ls''' | | '''docker network ls''' |
| Line 94: |
Line 91: |
| | with '''newnetwork''' | | with '''newnetwork''' |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Terminal Command: | + | || Terminal Command: |
| | | | |
| | Highlight '''container id''' | | Highlight '''container id''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Next, let's connect containers. | + | || Next, let's connect containers. |
| | | | |
| − | <div style="color:#000000;">We will be using a '''nginx '''docker image.</div>
| + | We will be using a '''nginx '''docker image. |
| | | | |
| − | <div style="color:#000000;">We'll start a container and connect it to the network using the command as shown.</div>
| + | We'll start a container and connect it to the network using the command as shown. |
| | | | |
| | This command runs a container named '''container1''' and connects it to '''newnetwork.''' | | This command runs a container named '''container1''' and connects it to '''newnetwork.''' |
| | | | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Terminal Command: | + | || Terminal Command: |
| | | | |
| | Highlight '''container id''' | | Highlight '''container id''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Similarly, let us run another container named container2 with '''curlimages/curl '''image | + | || Similarly, let us run another container named container2 with '''curlimages/curl '''image |
| | | | |
| | Type the command as shown. | | Type the command as shown. |
| Line 121: |
Line 118: |
| | They can communicate with each other. | | They can communicate with each other. |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Terminal Command: | + | || Terminal Command: |
| | | | |
| | Highlight '''response''' | | Highlight '''response''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | To check the connectivity between containers, we use the command, as shown. | + | || To check the connectivity between containers, we use the command, as shown. |
| | | | |
| | The containers will return a webpage response. | | The containers will return a webpage response. |
| Line 130: |
Line 127: |
| | The response will contain '''nginx''' welcome page in html format | | The response will contain '''nginx''' welcome page in html format |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Only narration. | + | || Only narration. |
| | + | || Now, let's learn about exposing ports. |
| | | | |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Now, let's learn about exposing ports.
| + | Ports expose Docker container services to the host or other networks |
| − | <div style="color:#000000;">Ports expose Docker container services to the host or other networks</div>
| + | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Terminal Command: | + | || Terminal Command: |
| | | | |
| | '''docker run -d -p 8080:80 nginx''' | | '''docker run -d -p 8080:80 nginx''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | For example, to bind port 8080 on your host to port 80 in the '''container''', use | + | || For example, to bind port 8080 on your host to port 80 in the '''container''', use |
| | | | |
| | '''docker space run space hyphen d space hyphen p space 8080:80 space nginx '''and press '''Enter''' | | '''docker space run space hyphen d space hyphen p space 8080:80 space nginx '''and press '''Enter''' |
| Line 148: |
Line 145: |
| | We can access this via port '''8080''' on the host machine | | We can access this via port '''8080''' on the host machine |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Open Firefox browser. | + | || Open Firefox browser. |
| | | | |
| | Type the URL [http://localhost:8080/ http://localhost:8080] | | Type the URL [http://localhost:8080/ http://localhost:8080] |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Now let us view the running nginx web server. | + | || Now let us view the running nginx web server. |
| | | | |
| | Open the web browser and type the url | | Open the web browser and type the url |
| Line 158: |
Line 155: |
| | | | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | The''' nginx welcome '''page will open | + | || The''' nginx welcome '''page will open |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | This is the welcome page for nginx web server. | + | || This is the welcome page for nginx web server. |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Terminal Command | + | || Terminal Command |
| | | | |
| | '''docker network ls''' | | '''docker network ls''' |
| Line 167: |
Line 164: |
| | All the docker network with network id will appear | | All the docker network with network id will appear |
| | | | |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Switching back to the terminal. | + | || Switching back to the terminal. |
| | | | |
| | Let us see how to delete a created network. | | Let us see how to delete a created network. |
| Line 178: |
Line 175: |
| | | | |
| | |- | | |- |
| − | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || '''docker network rm <NETWORK_ID>''' |
| − | | + | ||To remove the network we will use the remove command with network id. |
| − | '''docker network rm <NETWORK_ID>''' | + | |
| − | | + | |
| − | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | |
| − | | + | |
| − | To remove the network we will use the remove command with network id. | + | |
| | | | |
| | Let us remove the third network from the list. | | Let us remove the third network from the list. |
| Line 192: |
Line 184: |
| | Type '''docker space network space rm and paste the id.''' | | Type '''docker space network space rm and paste the id.''' |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | '''Error appears ''' | + | || '''Error appears ''' |
| | | | |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | This error appears because some containers are using the '''newnetwork''' | + | || This error appears because some containers are using the '''newnetwork''' |
| | | | |
| | To fix this error we have to first stop all the containers using the network '''newnetwork''' | | To fix this error we have to first stop all the containers using the network '''newnetwork''' |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || '''docker ps -q --filter "network=newnetwork" | xargs docker stop''' |
| − | | + | || To stop all the containers under the same network. |
| − | <div style="color:#ff0000;"></div>
| + | |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | To stop all the containers under the same network. | + | |
| | | | |
| | Type the command as shown. | | Type the command as shown. |
| | | | |
| − | '''docker ps -q --filter "network=newnetwork" | xargs docker stop'''
| |
| | | | |
| | It displays the container id that are stopped which used '''newnetwork''' as network | | It displays the container id that are stopped which used '''newnetwork''' as network |
| | | | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || Type '''docker space network space rm and paste the id.''' |
| − | | + | || Now we can remove the network. |
| − | Type '''docker space network space rm and paste the id.''' | + | |
| − | | + | |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Now we can remove the network. | + | |
| | | | |
| | Type '''docker network ls''' | | Type '''docker network ls''' |
| Line 229: |
Line 215: |
| | | | |
| | |- | | |- |
| − | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || '''docker network prune''' |
| − | | + | |
| − | '''docker network prune''' | + | |
| | | | |
| | A warning will appear | | A warning will appear |
| Line 239: |
Line 223: |
| | '''Are you sure you want to continue? [y/N]''' | | '''Are you sure you want to continue? [y/N]''' |
| | | | |
| − | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | | + | || You can also remove all the unused '''docker network '''at once. |
| − | | + | |
| − | You can also remove all the unused '''docker network '''at once. | + | |
| | | | |
| | For that type | | For that type |
| Line 252: |
Line 234: |
| | | | |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Clicking on terminal close button | + | || Clicking on terminal close button |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Close the t'''erminal window.''' | + | || Close the '''terminal window.''' |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''Summary''' | | '''Summary''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | This brings us to the end of this tutorial. Let us summarize. | + | || This brings us to the end of this tutorial. Let us summarize. |
| | | | |
| | In this tutorial, we learnt about | | In this tutorial, we learnt about |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Fundamentals of Docker networking</div> | + | * Fundamentals of Docker networking |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Connecting containers and establishing communication links</div> | + | * Connecting containers and establishing communication links |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Configuring port exposure and service exposure</div> | + | * Configuring port exposure and service exposure |
| − | * <div style="margin-left:1.27cm;margin-right:0cm;">Deleting docker network</div> | + | * Deleting docker network |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: '''About Spoken Tutorial project''' | + | || Show Slide: '''About Spoken Tutorial project''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | The video at the following link summarizes the '''Spoken Tutorial project'''. | + | || The video at the following link summarizes the '''Spoken Tutorial project'''. |
| | | | |
| | Please download and watch it | | Please download and watch it |
| | |- | | |- |
| − | | style="background-color:#ffffff;border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.095cm;padding-right:0.191cm;" | Show Slide: '''Spoken Tutorial Workshops''' | + | || Show Slide: '''Spoken Tutorial Workshops''' |
| − | | style="border-top:0.5pt solid #000000;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.079cm;padding-right:0.191cm;" | <span style="background-color:#ffffff;">The </span><span style="background-color:#ffffff;">'''Spoken Tutorial Project'''</span><span style="background-color:#ffffff;"> team </span>conducts workshops and gives certificates. | + | || The '''Spoken Tutorial Project''' team conducts workshops and gives certificates. |
| | | | |
| | For more details, please write to us. | | For more details, please write to us. |
| | |- | | |- |
| − | | style="background-color:#ffffff;border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.095cm;padding-right:0.191cm;" | Show Slide: | + | || Show Slide: |
| | | | |
| | '''Answers for THIS Spoken Tutorial''' | | '''Answers for THIS Spoken Tutorial''' |
| − | | style="background-color:#ffffff;border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.095cm;padding-right:0.191cm;" | Please post your timed queries in this forum. | + | || Please post your timed queries in this forum. |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide: '''FOSSEE Forum''' | + | || Show Slide: '''FOSSEE Forum''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | For any general or technical questions on '''Docker''', visit the FOSSEE forum and post your question. | + | || For any general or technical questions on '''Docker''', visit the FOSSEE forum and post your question. |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Slide: '''Acknowledgement''' | + | || Slide: '''Acknowledgement''' |
| | | | |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | '''Spoken Tutorial '''Project<span style="color:#ff0000;"> </span>was established by the''' Ministry of Education''',''' Government of India'''. | + | || '''Spoken Tutorial '''Project was established by the''' Ministry of Education''',''' Government of India'''. |
| | |- | | |- |
| − | | style="border-top:0.5pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | <div style="color:#000000;">Show slide:</div> | + | || Show slide: |
| | | | |
| − | <div style="color:#000000;">'''Thank You'''</div>
| + | '''Thank You''' |
| − | | style="border:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | This is Aditya Kushwaha, a FOSSEE Semester long intern 2024, IIT Bombay, signing off. | + | || This is Aditya Kushwaha, a FOSSEE Semester long intern 2024, IIT Bombay, signing off. |
| | | | |
| | Thanks for joining. | | Thanks for joining. |
| | |- | | |- |
| | |} | | |} |
| Visual Cue
|
Narration
|
| Show Slide:
Title Slide
|
Hello and welcome to the Spoken Tutorial on “Docker Networking”.
|
| Show Slide:
Learning Objectives
|
In this tutorial, we will learn about:
- Fundamentals of Docker networking.
- Connecting containers and establishing communication links.
- Configuring port exposure and service exposure.
- Deleting docker network
|
| Show Slide:
System Requirements
|
To record this tutorial, I am using
- Ubuntu Linux OS version 22.04
- Docker version 27.0.2
|
| Show Slide:
Prerequisite
|
To follow this tutorial,
- You must have basic knowledge of using Linux terminal
- For pre-requisite Linux tutorials, please visit this website
|
| Show Slide:
Fundamentals of Docker networking
|
- Docker networking involves various components and configurations
- Docker uses network namespaces to isolate network resources.
- Docker facilitates this through network links and service discovery mechanisms
|
| Show Slide:
Types of Docker networks
|
| Docker provides several types of networks:
|
- Bridge Network:It is the default network type
- Host Network: The Containers share the host’s network stack
- Overlay Network: It enables communication between containers
- Macvlan Network: It assigns a MAC address to each container, making it appear as a physical device
- None Network: It disables networking for the container
|
|
|
In this tutorial we will demonstrate how to use Bridge Network.
|
| Open Linux terminal
Create a Docker network
Type command docker network create newnetwork in terminal
Highlight network id
|
Open your terminal.
Let us first create a docker network.
To create a docker network
Type docker space network space create space newnetwork and press Enter
Here, newnetwork is the name of the network.
We can see a network id as output related to the created network.
|
| Type command
docker network ls
|
To view all the docker network, type the command
docker network ls
Here you can see all the docker networks
with newnetwork
|
| Terminal Command:
Highlight container id
|
Next, let's connect containers.
We will be using a nginx docker image.
We'll start a container and connect it to the network using the command as shown.
This command runs a container named container1 and connects it to newnetwork.
|
| Terminal Command:
Highlight container id
|
Similarly, let us run another container named container2 with curlimages/curl image
Type the command as shown.
Here the nginx container is serving as the server
And we will use the curl container to act as the client
Now, both containers are connected to the same network.
They can communicate with each other.
|
| Terminal Command:
Highlight response
|
To check the connectivity between containers, we use the command, as shown.
The containers will return a webpage response.
The response will contain nginx welcome page in html format
|
| Only narration.
|
Now, let's learn about exposing ports.
Ports expose Docker container services to the host or other networks
|
| Terminal Command:
docker run -d -p 8080:80 nginx
|
For example, to bind port 8080 on your host to port 80 in the container, use
docker space run space hyphen d space hyphen p space 8080:80 space nginx and press Enter
This command exposes port 80 of the container nginx to port 8080 on the host.
Now, service is running on port 80 within the container.
We can access this via port 8080 on the host machine
|
| Open Firefox browser.
Type the URL http://localhost:8080
|
Now let us view the running nginx web server.
Open the web browser and type the url
http://localhost:8080
|
| The nginx welcome page will open
|
This is the welcome page for nginx web server.
|
| Terminal Command
docker network ls
All the docker network with network id will appear
|
Switching back to the terminal.
Let us see how to delete a created network.
Type
docker space network space ls
Here we can see all the docker networks
|
| docker network rm <NETWORK_ID>
|
To remove the network we will use the remove command with network id.
Let us remove the third network from the list.
copy the network_id
Type docker space network space rm and paste the id.
|
| Error appears
|
This error appears because some containers are using the newnetwork
To fix this error we have to first stop all the containers using the network newnetwork
|
| docker ps -q --filter "network=newnetwork" | xargs docker stop
|
To stop all the containers under the same network.
Type the command as shown.
It displays the container id that are stopped which used newnetwork as network
|
| Type docker space network space rm and paste the id.
|
Now we can remove the network.
Type docker network ls
To remove the network we will use the remove command with network id.
Let us remove the third network from the list.
copy the network id
Type docker space network space rm and paste the id.
The network newnetwork is successfully removed with network id as shown.
|
| docker network prune
A warning will appear
WARNING! This will remove all custom networks not used by at least one container.
Are you sure you want to continue? [y/N]
|
You can also remove all the unused docker network at once.
For that type
docker space network space prune
A warning will appear.
Type y and press Enter to continue removing the docker networks
|
| Clicking on terminal close button
|
Close the terminal window.
|
| Show Slide:
Summary
|
This brings us to the end of this tutorial. Let us summarize.
In this tutorial, we learnt about
- Fundamentals of Docker networking
- Connecting containers and establishing communication links
- Configuring port exposure and service exposure
- Deleting docker network
|
| Show Slide: About Spoken Tutorial project
|
The video at the following link summarizes the Spoken Tutorial project.
Please download and watch it
|
| Show Slide: Spoken Tutorial Workshops
|
The Spoken Tutorial Project team conducts workshops and gives certificates.
For more details, please write to us.
|
| Show Slide:
Answers for THIS Spoken Tutorial
|
Please post your timed queries in this forum.
|
| Show Slide: FOSSEE Forum
|
For any general or technical questions on Docker, visit the FOSSEE forum and post your question.
|
| Slide: Acknowledgement
|
Spoken Tutorial Project was established by the Ministry of Education, Government of India.
|
| Show slide:
Thank You
|
This is Aditya Kushwaha, a FOSSEE Semester long intern 2024, IIT Bombay, signing off.
Thanks for joining.
|