Merge pull request #36396 from selansen/master
Allow user to specify default address pools for docker networks Upstream-commit: 82d9185470c99d5768b60926648b3739ec15bbc4 Component: engine
This commit is contained in:
@@ -71,6 +71,12 @@ type commonBridgeConfig struct {
|
||||
FixedCIDR string `json:"fixed-cidr,omitempty"`
|
||||
}
|
||||
|
||||
// NetworkConfig stores the daemon-wide networking configurations
|
||||
type NetworkConfig struct {
|
||||
// Default address pools for docker networks
|
||||
DefaultAddressPools opts.PoolsOpt `json:"default-address-pools,omitempty"`
|
||||
}
|
||||
|
||||
// CommonTLSOptions defines TLS configuration for the daemon server.
|
||||
// It includes json tags to deserialize configuration from a file
|
||||
// using the same names that the flags in the command line use.
|
||||
@@ -173,6 +179,7 @@ type CommonConfig struct {
|
||||
|
||||
LogConfig
|
||||
BridgeConfig // bridgeConfig holds bridge network specific configuration.
|
||||
NetworkConfig
|
||||
registry.ServiceOptions
|
||||
|
||||
sync.Mutex
|
||||
|
||||
@@ -23,7 +23,6 @@ type Config struct {
|
||||
|
||||
// These fields are common to all unix platforms.
|
||||
CommonUnixConfig
|
||||
|
||||
// Fields below here are platform specific.
|
||||
CgroupParent string `json:"cgroup-parent,omitempty"`
|
||||
EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"`
|
||||
|
||||
@@ -1223,6 +1223,10 @@ func (daemon *Daemon) networkOptions(dconfig *config.Config, pg plugingetter.Plu
|
||||
options = append(options, nwconfig.OptionLabels(dconfig.Labels))
|
||||
options = append(options, driverOptions(dconfig)...)
|
||||
|
||||
if len(dconfig.NetworkConfig.DefaultAddressPools.Value()) > 0 {
|
||||
options = append(options, nwconfig.OptionDefaultAddressPoolConfig(dconfig.NetworkConfig.DefaultAddressPools.Value()))
|
||||
}
|
||||
|
||||
if daemon.configStore != nil && daemon.configStore.LiveRestoreEnabled && len(activeSandboxes) != 0 {
|
||||
options = append(options, nwconfig.OptionActiveSandboxes(activeSandboxes))
|
||||
}
|
||||
|
||||
@@ -833,6 +833,9 @@ func (daemon *Daemon) initNetworkController(config *config.Config, activeSandbox
|
||||
if err = n.Delete(); err != nil {
|
||||
return nil, fmt.Errorf("could not delete the default bridge network: %v", err)
|
||||
}
|
||||
if len(config.NetworkConfig.DefaultAddressPools.Value()) > 0 && !daemon.configStore.LiveRestoreEnabled {
|
||||
removeDefaultBridgeInterface()
|
||||
}
|
||||
}
|
||||
|
||||
if !config.DisableBridge {
|
||||
|
||||
Reference in New Issue
Block a user