diff --git a/daemon/container_operations.go b/daemon/container_operations.go index 3bd50fa31f..1bc828dcda 100644 --- a/daemon/container_operations.go +++ b/daemon/container_operations.go @@ -511,7 +511,7 @@ func (daemon *Daemon) updateNetworkConfig(container *container.Container, idOrNa } if !containertypes.NetworkMode(idOrName).IsUserDefined() { - if hasUserDefinedIPAddress(endpointConfig) { + if hasUserDefinedIPAddress(endpointConfig) && !enableIPOnPredefinedNetwork() { return nil, runconfig.ErrUnsupportedNetworkAndIP } if endpointConfig != nil && len(endpointConfig.Aliases) > 0 { diff --git a/daemon/container_operations_unix.go b/daemon/container_operations_unix.go index 55bd3fc839..d2b849445e 100644 --- a/daemon/container_operations_unix.go +++ b/daemon/container_operations_unix.go @@ -383,3 +383,7 @@ func isLinkable(child *container.Container) bool { func errRemovalContainer(containerID string) error { return fmt.Errorf("Container %s is marked for removal and cannot be connected or disconnected to the network", containerID) } + +func enableIPOnPredefinedNetwork() bool { + return false +} diff --git a/daemon/container_operations_windows.go b/daemon/container_operations_windows.go index 32d18c2fa3..16f0c81509 100644 --- a/daemon/container_operations_windows.go +++ b/daemon/container_operations_windows.go @@ -55,3 +55,7 @@ func killProcessDirectly(container *container.Container) error { func isLinkable(child *container.Container) bool { return false } + +func enableIPOnPredefinedNetwork() bool { + return true +}