commit
beeec6d103
2 changed files with 13 additions and 3 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue