Warn when using host-ip for published ports

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 363335ec9b
Component: cli
This commit is contained in:
Sebastiaan van Stijn
2017-12-12 16:45:19 -08:00
parent 4e1a92ff17
commit 13669fec1f

View File

@ -9,6 +9,7 @@ import (
"github.com/docker/docker/api/types/swarm"
"github.com/docker/go-connections/nat"
"github.com/sirupsen/logrus"
)
const (
@ -147,6 +148,9 @@ func ConvertPortToPortConfig(
ports := []swarm.PortConfig{}
for _, binding := range portBindings[port] {
if binding.HostIP != "" && binding.HostIP != "0.0.0.0" {
logrus.Warnf("ignoring IP-address (%s:%s:%s) service will listen on '0.0.0.0'", binding.HostIP, binding.HostPort, port)
}
hostPort, err := strconv.ParseUint(binding.HostPort, 10, 16)
if err != nil && binding.HostPort != "" {
return nil, fmt.Errorf("invalid hostport binding (%s) for port (%s)", binding.HostPort, port.Port())