瀏覽代碼

Merge pull request #22820 from thaJeztah/suppress-incorrect-warning

Suppress "IPv4 forwarding" warning for --net=host
Vincent Demeester 9 年之前
父節點
當前提交
52debcd58a
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 3 1
      daemon/daemon_unix.go
  2. 3 0
      docs/userguide/networking/default_network/container-communication.md

+ 3 - 1
daemon/daemon_unix.go

@@ -488,7 +488,9 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
 	if hostConfig.OomScoreAdj < -1000 || hostConfig.OomScoreAdj > 1000 {
 		return warnings, fmt.Errorf("Invalid value %d, range for oom score adj is [-1000, 1000]", hostConfig.OomScoreAdj)
 	}
-	if sysInfo.IPv4ForwardingDisabled {
+
+	// ip-forwarding does not affect container with '--net=host'
+	if sysInfo.IPv4ForwardingDisabled && !hostConfig.NetworkMode.IsHost() {
 		warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.")
 		logrus.Warnf("IPv4 forwarding is disabled. Networking will not work")
 	}

+ 3 - 0
docs/userguide/networking/default_network/container-communication.md

@@ -37,6 +37,9 @@ or to turn it on manually:
   net.ipv4.conf.all.forwarding = 1
 ```
 
+> **Note**: this setting does not affect containers that use the host
+> network stack (`--net=host`).
+
 Many using Docker will want `ip_forward` to be on, to at least make
 communication _possible_ between containers and the wider world. May also be
 needed for inter-container communication if you are in a multiple bridge setup.