Browse code

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 <github@gone.nl>

Sebastiaan van Stijn authored on 2018/12/19 06:42:57
Showing 2 changed files
... ...
@@ -351,8 +351,5 @@ func (daemon *Daemon) verifyContainerSettings(platform string, hostConfig *conta
351 351
 	if warnings, err = verifyPlatformContainerSettings(daemon, hostConfig, config, update); err != nil {
352 352
 		return warnings, err
353 353
 	}
354
-	if hostConfig.NetworkMode.IsHost() && len(hostConfig.PortBindings) > 0 {
355
-		warnings = append(warnings, "Published ports are discarded when using host network mode")
356
-	}
357 354
 	return warnings, err
358 355
 }
... ...
@@ -607,6 +607,10 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
607 607
 		warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.")
608 608
 		logrus.Warn("IPv4 forwarding is disabled. Networking will not work")
609 609
 	}
610
+	if hostConfig.NetworkMode.IsHost() && len(hostConfig.PortBindings) > 0 {
611
+		warnings = append(warnings, "Published ports are discarded when using host network mode")
612
+	}
613
+
610 614
 	// check for various conflicting options with user namespaces
611 615
 	if daemon.configStore.RemappedRoot != "" && hostConfig.UsernsMode.IsPrivate() {
612 616
 		if hostConfig.Privileged {