0% found this document useful (0 votes)
16 views5 pages

Docker-Overlay Network

Docker overlay networks enable communication between containers across multiple Docker hosts, essential for distributed applications. They are utilized in Docker Swarm, allowing for high availability, load balancing, and easy scaling of applications. Key features include encapsulation of data, service discovery, security, and dynamic updates, making them a powerful networking solution in clustered environments.

Uploaded by

Iftikhar Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

Docker-Overlay Network

Docker overlay networks enable communication between containers across multiple Docker hosts, essential for distributed applications. They are utilized in Docker Swarm, allowing for high availability, load balancing, and easy scaling of applications. Key features include encapsulation of data, service discovery, security, and dynamic updates, making them a powerful networking solution in clustered environments.

Uploaded by

Iftikhar Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Overlay Network:

In the context of Docker, an overlay network is a network that spans multiple Docker daemon hosts,
allowing containers on different hosts to communicate with each other. This becomes particularly
useful in a distributed application where containers might be running on different machines but
need to work together.

Let’s say you are working on Kubernetes cluster (k8s) or Docker Swarm where in your whole network
you have multiple machines. Inside the machines there are multiple containers are running. All
together they are on a cluster.

In sort, if you use multiple hosts you need overlay network.

Let’s do some practical on this. In order to do the project/practical I will user Docker Swarm.

What is Docker Swarm?

Docker Swarm is a native clustering and orchestration solution for Docker. It allows you to create
and manage a swarm of Docker nodes, turning them into a single, virtual Docker engine. This
enables you to deploy and manage containers at scale, providing features for high availability, load
balancing, and easy scaling of applications.

We will have separate project on Docker Swarm, for now just follow as per below.

➢ Create 2 ec2 instances. One will be our master another one will be worker.
➢ In one node which you want to make master, run docker swarm init command with below
arguments

$docker swarm init --advertise-addr 13.232.39.74

Here in the command the ip is the public IP of you node/master which you want to make.

➢ Once you run that command you will get a token generated in your screen along with
command , you need to run it to another node which will be your worker.
Now your manger and worker are connected to each other through docker swarm.

➢ Let’s see more on this:-

In below screen shot you can see node details :-


➢ Now our main project on overlay network.
➢ Create an overlay network first with below command

$docker network create -d overlay overnet

(-d is driver , for us driver is overlay


Overnet is the name of our network we have given.)

➢ Now create a service with below arguments.

$docker service create --name=my-service --network=overnet --replicas=2 nginx:latest

[Service name is my-service, 2 replicas will be created using overnet network which we just created
(overlay) and nginx containers will be running]

➢ The service is the main which will help both the node’s containers to be connected through
overlay network. It’s kind of handshaking between multiple hosts containers.
➢ Below are the commands in screen shot to verify.

$docker service ls

$docker service ps my-service


➢ Now inspect our overlay network and see if the containers are running on same subnet
under overlay network or not.

$ docker network inspect overnet

As you can see both containers are running in same subnet range in a same Docker network which is
overlay. They both should be talk to each other.
Please do the practical with other image and try pinging. How to do that? Check my another
post/document on Custom bridge network you will get the steps.

https://www.linkedin.com/posts/avik-dutta-ba4b2952_docker-host-custom-bridge-nw-activity-
7151792517540147202-6bc-?utm_source=share&utm_medium=member_desktop

Here are some key points about Docker overlay networks:

Multi-Host Communication: Overlay networks enable communication between containers running


on different Docker hosts. It essentially creates a virtual network that sits on top of the existing
infrastructure, allowing containers to communicate seamlessly regardless of the physical machine
they are on.

Encapsulation: When containers communicate over an overlay network, the data is encapsulated.
This means that the details of how the communication happens are abstracted away, making it
easier for containers to talk to each other without worrying about the intricacies of the underlying
network.

Swarm Mode: Docker Swarm, which is Docker's native clustering and orchestration solution, often
utilizes overlay networks. In a Swarm cluster, overlay networks help in connecting services and
distributing them across multiple nodes while ensuring they can communicate effortlessly.

Service Discovery: Overlay networks facilitate service discovery. Containers can be referred to by
their service names, and Docker's built-in DNS server takes care of routing requests to the
appropriate container. This simplifies the way containers find and communicate with each other.

Security: Overlay networks provide isolation and security. Communication within the overlay
network is confined to the containers connected to it, and the underlying physical network doesn't
need to be aware of the details of container communication.

Dynamic Updates: Overlay networks support dynamic updates. If you add or remove containers
from the network, the overlay network adapts to these changes automatically, making it flexible and
scalable.

In summary, Docker overlay networks offer a powerful solution for networking in distributed and
clustered environments. They allow containers to communicate seamlessly across multiple hosts,
providing a virtual network that simplifies the complexities of distributed application architectures.

You might also like