Merge pull request #1017 from thaJeztah/warn-when-using-host-ip

Warn when using host-ip for published ports
This commit is contained in:
Brian Goff 2018-04-25 17:09:42 -04:00 committed by GitHub
commit 99bd7ed693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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())