Warn when using host-ip for published ports

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2017-12-12 16:45:19 -08:00
parent 6c9232a568
commit 363335ec9b
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 4 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
"github.com/sirupsen/logrus"
) )
const ( const (
@ -147,6 +148,9 @@ func ConvertPortToPortConfig(
ports := []swarm.PortConfig{} ports := []swarm.PortConfig{}
for _, binding := range portBindings[port] { 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) hostPort, err := strconv.ParseUint(binding.HostPort, 10, 16)
if err != nil && binding.HostPort != "" { if err != nil && binding.HostPort != "" {
return nil, fmt.Errorf("invalid hostport binding (%s) for port (%s)", binding.HostPort, port.Port()) return nil, fmt.Errorf("invalid hostport binding (%s) for port (%s)", binding.HostPort, port.Port())