From 89c6febfc2b1fd69babdbaba24fa67b76c3be651 Mon Sep 17 00:00:00 2001 From: Pradip Dhara Date: Wed, 6 Nov 2019 10:54:28 -0800 Subject: [PATCH] Dockerd won't start if a network with the default subnet prefix already exists in HNS. Signed-off-by: Pradip Dhara --- daemon/daemon_windows.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index f7d557fb84..95d15233c5 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -33,7 +33,6 @@ import ( const ( isWindows = true - defaultNetworkSpace = "172.16.0.0/12" platformSupported = true windowsMinCPUShares = 1 windowsMaxCPUShares = 10000 @@ -424,15 +423,19 @@ func initBridgeDriver(controller libnetwork.NetworkController, config *config.Co winlibnetwork.NetworkName: runconfig.DefaultDaemonNetworkMode().NetworkName(), } - subnetPrefix := defaultNetworkSpace + var ipamOption libnetwork.NetworkOption + var subnetPrefix string + if config.BridgeConfig.FixedCIDR != "" { subnetPrefix = config.BridgeConfig.FixedCIDR } - ipamV4Conf := libnetwork.IpamConf{PreferredPool: subnetPrefix} - v4Conf := []*libnetwork.IpamConf{&ipamV4Conf} - v6Conf := []*libnetwork.IpamConf{} - ipamOption := libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil) + if subnetPrefix != "" { + ipamV4Conf := libnetwork.IpamConf{PreferredPool: subnetPrefix} + v4Conf := []*libnetwork.IpamConf{&ipamV4Conf} + v6Conf := []*libnetwork.IpamConf{} + ipamOption = libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil) + } _, err := controller.NewNetwork(string(runconfig.DefaultDaemonNetworkMode()), runconfig.DefaultDaemonNetworkMode().NetworkName(), "", libnetwork.NetworkOptionGeneric(options.Generic{