DOCKER – Get published port for a service

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}}'

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.