Merge pull request #17558 from aboch/nw
Fix bug in initializeNetwork() Upstream-commit: beeec6d103cadb037ccd5f9bc4c6647ae74a6b45 Component: engine
This commit is contained in:
@ -913,6 +913,13 @@ func (container *Container) allocateNetwork() error {
|
||||
if mode.IsDefault() {
|
||||
networkName = controller.Config().Daemon.DefaultNetwork
|
||||
}
|
||||
if mode.IsUserDefined() {
|
||||
n, err := container.daemon.FindNetwork(networkName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
networkName = n.Name()
|
||||
}
|
||||
container.NetworkSettings.Networks = make(map[string]*network.EndpointSettings)
|
||||
container.NetworkSettings.Networks[networkName] = new(network.EndpointSettings)
|
||||
updateSettings = true
|
||||
@ -953,9 +960,7 @@ func (container *Container) ConnectToNetwork(idOrName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (container *Container) connectToNetwork(idOrName string, updateSettings bool) error {
|
||||
var err error
|
||||
|
||||
func (container *Container) connectToNetwork(idOrName string, updateSettings bool) (err error) {
|
||||
if container.hostConfig.NetworkMode.IsContainer() {
|
||||
return runconfig.ErrConflictSharedNetwork
|
||||
}
|
||||
|
||||
@ -733,3 +733,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRe
|
||||
|
||||
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList)
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *check.C) {
|
||||
out, _ := dockerCmd(c, "network", "create", "one")
|
||||
dockerCmd(c, "run", "-d", "--net", strings.TrimSpace(out), "busybox", "top")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user