If you want/need to get the given Published Port for a determinated target port in a docker service you can use:
docker service inspect <strong>SERVICE_NAME</strong> --format='{{range .Endpoint.Ports}}{{if eq .TargetPort 8080}}{{.PublishedPort}}{{end}}{{end}}'