From 2e23ef5350f1cee4e20f68bf79b335e2c386303e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 18 Dec 2018 22:42:57 +0100 Subject: [PATCH] Move port-publishing check to linux platform-check Windows does not have host-mode networking, so on Windows, this check was a no-op Signed-off-by: Sebastiaan van Stijn --- daemon/container.go | 3 --- daemon/daemon_unix.go | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/daemon/container.go b/daemon/container.go index c8e2053970..07fab41c3d 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -351,8 +351,5 @@ func (daemon *Daemon) verifyContainerSettings(platform string, hostConfig *conta if warnings, err = verifyPlatformContainerSettings(daemon, hostConfig, config, update); err != nil { return warnings, err } - if hostConfig.NetworkMode.IsHost() && len(hostConfig.PortBindings) > 0 { - warnings = append(warnings, "Published ports are discarded when using host network mode") - } return warnings, err } diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index d38988c127..9f5bd17d29 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -607,6 +607,10 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.") logrus.Warn("IPv4 forwarding is disabled. Networking will not work") } + if hostConfig.NetworkMode.IsHost() && len(hostConfig.PortBindings) > 0 { + warnings = append(warnings, "Published ports are discarded when using host network mode") + } + // check for various conflicting options with user namespaces if daemon.configStore.RemappedRoot != "" && hostConfig.UsernsMode.IsPrivate() { if hostConfig.Privileged {