Docker Network Driver’s and Swarm Mode
One of the reasons Docker containers and services are so powerful is that you can connect them together using networks. There are different network driver’s to help to deploy your applications.
Network drivers
Bridge
The default network driver. If you don’t specify a driver, this is the type of network you are creating. Bridge networks are usually used when your applications run in standalone containers that need to communicate.
Host
For standalone containers, remove network isolation between the container and the Docker host, and use the host’s networking directly.
Overlay
Overlay networks connect multiple Docker daemons together and enable swarm services to communicate with each other.
Lets Start with network’s
1. Creating the swarm
$ docker swarm init --advertise-addr=<IP-ADDRESS-OF-MANAGER>
If the host only has one network interface, the --advertise-addr
flag is optional.
2. Join the swarm
$ docker swarm --join --token <TOKEN> \
--advertise-addr <IP-ADDRESS-OF-WORKER-2> \
<IP-ADDRESS-OF-MANAGER>:2377
3. List of all nodes
$ docker node ls
You can also use the --filter
flag to filter by role:
$ docker node ls --filter role=manager
4. List of all docker networks
$ docker network ls
If you create swarm services and do specify a network to connected.