I have a docker swarm cluster with following nodes
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
manager1 - virtualbox Running tcp://192.168.99.113:2376 v19.03.12
worker1 - virtualbox Running tcp://192.168.99.114:2376 v19.03.12
worker2 - virtualbox Running tcp://192.168.99.115:2376 v19.03.12
I have created service on manager node as follows
$ docker service create --name registry --publish 5000:5000 registry:2
Now I can access the service from any swarm node
$ curl localhost:5000/v2/_catalog
{"repositories":[]}
But If I try to access the service from outside swarm cluster I get this error
$ curl localhost:5000/v2/_catalog
curl: (7) Failed to connect to localhost port 5000: Connection refused
How can we access service running in swarm cluster from host machine
Finally I was able to access service with this command curl <manager/worker ip>:5000/v2/_catalog