Docker Community Forums

Share and learn in the Docker community.

Docker Swarm overlay network - unable to open webpage from different nodes

I am new to Docker Swarm. I have 3 nodes added to swarm:

ID                            HOSTNAME                                      STATUS              AVAILABILITY        MANAGER STATUS
5l5bh04q1lrhchq0mdr7t4w0k *   ip-172-31-45-243.us-west-2.compute.internal   Ready               Active              Leader
odf5tx9ynoqpvbsxfobs51cse     ip-172-31-36-22.us-west-2.compute.internal    Ready               Active              Reachable
t3qu3e7hyq2le50q35ycwqoos     ip-172-31-45-19.us-west-2.compute.internal    Ready               Active              Reachable

I created a service using this command, swrm is an overlay network:

docker service create --name server --network swrm --publish 80:80 httpd

Issue: I am able to access http port 80 only from the swarm node where the service task is started and not from other nodes which are a part of the swarm. e.g. If the task is started in ip-172-31-45-243.us-west-2.compute.internal, then I cannot access http port 80 from other nodes such as ip-172-31-36-22.us-west-2.compute.internal.

Please let me know how can I access http port 80 from either of the swarm nodes irrespective of the node where task is created. Please help.

What do you get when you run the following? (on any of the 3 nodes)

docker service ps server

also

docker service ls

Note: you are not including --replicas or --mode. So by default, I believe docker swarm will run just one replica of your service on one of the 3 nodes. However, you should be able to access your service on any of the nodes because the swarm load balancer will forward your request to a node that runs your service transparently.

Yes, it will run just one replica. And if it gets started in node 2, then I am unable to access the service from node 1 / node 3.

I tried stopping and starting the service multiple times and every time I am able to access it only from the node where it starts but not from the other nodes of the swarm.

Seems like routing mesh is not working properly, please help me to debug and fix this issue.

Check if you have the following ports open for nodes to communicate.

Port 7946 TCP/UDP
Port 4789 UDP

What is the output of service ls and ps for your swarm service?

Also posting errors, logs, and command line arguments on how you created the swarm init would help.

1 Like

Thanks Arul, opening UDP ports resolved the issue. Can you please share the reference doc so that I can take a look into it? Appreciate!

I suggest reading this quick tutorial from docker.com