1. List Existing Docker Networks
Start by checking the current Docker networks on your Swarm manager:2. Create a Custom Overlay Network
Overlay networks enable containers across multiple Docker hosts to communicate. To create a custom network namedkodekloudnet, run:
To specify your own IP range, add
--subnet and --gateway flags:3. Deploy a Service in Ingress Mode
Ingress mode distributes traffic across all nodes on the published port. Even if a task isn’t running on a specific node, it will forward traffic to an active task elsewhere.--publish published=80,target=80uses the Swarm ingress load-balancer.- Access the application via any manager or worker node IP:
http://<node-ip>/
4. Deploy a Service in Host Mode
Host mode binds the published port directly on each node where a task is running. Nodes without a task on port 80 will not respond.- Traffic is only served on nodes hosting a task.
- Ensure your load balancer or DNS directs requests to the correct node IPs.