
Overlay network driver Explain
Learn about Docker's Overlay network driver: Connect containers across multiple hosts, enabling seamless communication in Swarm or multi-host setups.
overlay
network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of (overlays) the host-specific networks, allowing containers connected to it to communicate securely when encryption is enabled. Docker transparently handles routing of each packet to and from the correct Docker daemon host and the correct destination container.overlay
networks using docker network create
, in the same way that you can create user-defined bridge
networks. Services or containers can be connected to more than one network at a time. Services or containers can only communicate across networks they're each connected to.2377/tcp:
The default Swarm control plane port, is configurable with docker swarm join --listen-addr
4789/udp:
The default overlay traffic port, configurable with docker swarm init --data-path-addr
7946/tcp
, 7946/udp:
Used for communication among nodes, not configurable1
docker swarm init
docker network create
command with the --driver
option set to overlay
. Optionally, you can specify additional parameters such as subnet, gateway, and network name.1
docker network create --driver overlay my-overlay-network
1
docker network create --driver overlay --subnet=10.0.1.0/24 --gateway=10.0.1.1 my-overlay-network
— attachable
Command:1
docker network create --driver overlay --attachable my-overlay-network
--attachable
option enables both standalone containers and Swarm services to connect to the overlay network. Without --attachable
, only Swarm services can connect to the network.docker network ls
command to list all networks and verify that your overlay network has been created:1
docker network ls
--opt encrypted
flag to encrypt the application data transmitted over the overlay network:1
2
3
4
5
docker network create \
--opt encrypted \
--driver overlay \
--attachable \
my-attachable-multi-host-network
multi-host-network
with a busybox
container:1
$ docker run --network multi-host-network busybox sh