Merge pull request #13757 from eolamey/13755-we-would-like-default-gateway-back-please
Restore --default-gateway{,-v6} daemon options.
This commit is contained in:
commit
3d10540bc3
3 changed files with 55 additions and 4 deletions
|
@ -42,8 +42,8 @@ type bridgeConfig struct {
|
|||
IP string
|
||||
FixedCIDR string
|
||||
FixedCIDRv6 string
|
||||
DefaultGatewayIPv4 string
|
||||
DefaultGatewayIPv6 string
|
||||
DefaultGatewayIPv4 net.IP
|
||||
DefaultGatewayIPv6 net.IP
|
||||
InterContainerCommunication bool
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ func (config *Config) InstallFlags() {
|
|||
flag.StringVar(&config.Bridge.Iface, []string{"b", "-bridge"}, "", "Attach containers to a network bridge")
|
||||
flag.StringVar(&config.Bridge.FixedCIDR, []string{"-fixed-cidr"}, "", "IPv4 subnet for fixed IPs")
|
||||
flag.StringVar(&config.Bridge.FixedCIDRv6, []string{"-fixed-cidr-v6"}, "", "IPv6 subnet for fixed IPs")
|
||||
flag.StringVar(&config.Bridge.DefaultGatewayIPv4, []string{"-default-gateway"}, "", "Container default gateway IPv4 address")
|
||||
flag.StringVar(&config.Bridge.DefaultGatewayIPv6, []string{"-default-gateway-v6"}, "", "Container default gateway IPv6 address")
|
||||
opts.IPVar(&config.Bridge.DefaultGatewayIPv4, []string{"-default-gateway"}, "", "Container default gateway IPv4 address")
|
||||
opts.IPVar(&config.Bridge.DefaultGatewayIPv6, []string{"-default-gateway-v6"}, "", "Container default gateway IPv6 address")
|
||||
flag.BoolVar(&config.Bridge.InterContainerCommunication, []string{"#icc", "-icc"}, true, "Enable inter-container communication")
|
||||
opts.IPVar(&config.Bridge.DefaultIP, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP when binding container ports")
|
||||
flag.BoolVar(&config.Bridge.EnableUserlandProxy, []string{"-userland-proxy"}, true, "Use userland proxy for loopback traffic")
|
||||
|
|
|
@ -946,6 +946,14 @@ func initNetworkController(config *Config) (libnetwork.NetworkController, error)
|
|||
netOption["FixedCIDRv6"] = fCIDRv6
|
||||
}
|
||||
|
||||
if config.Bridge.DefaultGatewayIPv4 != nil {
|
||||
netOption["DefaultGatewayIPv4"] = config.Bridge.DefaultGatewayIPv4
|
||||
}
|
||||
|
||||
if config.Bridge.DefaultGatewayIPv6 != nil {
|
||||
netOption["DefaultGatewayIPv6"] = config.Bridge.DefaultGatewayIPv6
|
||||
}
|
||||
|
||||
// --ip processing
|
||||
if config.Bridge.DefaultIP != nil {
|
||||
netOption["DefaultBindingIP"] = config.Bridge.DefaultIP
|
||||
|
|
|
@ -526,6 +526,49 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *check.C) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *check.C) {
|
||||
defaultNetworkBridge := "docker0"
|
||||
deleteInterface(c, defaultNetworkBridge)
|
||||
|
||||
d := s.d
|
||||
|
||||
bridgeIp := "192.169.1.1"
|
||||
bridgeIpNet := fmt.Sprintf("%s/24", bridgeIp)
|
||||
|
||||
err := d.StartWithBusybox("--bip", bridgeIpNet)
|
||||
c.Assert(err, check.IsNil)
|
||||
defer d.Restart()
|
||||
|
||||
expectedMessage := fmt.Sprintf("default via %s dev", bridgeIp)
|
||||
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
|
||||
c.Assert(strings.Contains(out, expectedMessage), check.Equals, true,
|
||||
check.Commentf("Implicit default gateway should be bridge IP %s, but default route was '%s'",
|
||||
bridgeIp, strings.TrimSpace(out)))
|
||||
deleteInterface(c, defaultNetworkBridge)
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *check.C) {
|
||||
defaultNetworkBridge := "docker0"
|
||||
deleteInterface(c, defaultNetworkBridge)
|
||||
|
||||
d := s.d
|
||||
|
||||
bridgeIp := "192.169.1.1"
|
||||
bridgeIpNet := fmt.Sprintf("%s/24", bridgeIp)
|
||||
gatewayIp := "192.169.1.254"
|
||||
|
||||
err := d.StartWithBusybox("--bip", bridgeIpNet, "--default-gateway", gatewayIp)
|
||||
c.Assert(err, check.IsNil)
|
||||
defer d.Restart()
|
||||
|
||||
expectedMessage := fmt.Sprintf("default via %s dev", gatewayIp)
|
||||
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
|
||||
c.Assert(strings.Contains(out, expectedMessage), check.Equals, true,
|
||||
check.Commentf("Explicit default gateway should be %s, but default route was '%s'",
|
||||
gatewayIp, strings.TrimSpace(out)))
|
||||
deleteInterface(c, defaultNetworkBridge)
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonIP(c *check.C) {
|
||||
d := s.d
|
||||
|
||||
|
|
Loading…
Reference in a new issue