Get a list of all services on your swarm and their associated published ports:
docker service inspect \
--format="{{range .Spec.EndpointSpec.Ports}} {{$.Spec.Name}} on port {{.PublishedPort}} {{else}} {{$.Spec.Name}} exposes nothing {{end}}" \
`docker service ls|awk '{print $2;}'|tail -n +2`