mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #23011 from coolljt0725/fix_link
Fix link doesn't work sometimes when container start with multiple networks
This commit is contained in:
commit
1bbac428de
1 changed files with 14 additions and 0 deletions
|
@ -408,7 +408,21 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) error {
|
|||
updateSettings = true
|
||||
}
|
||||
|
||||
// always connect default network first since only default
|
||||
// network mode support link and we need do some setting
|
||||
// on sanbox initialize for link, but the sandbox only be initialized
|
||||
// on first network connecting.
|
||||
defaultNetName := runconfig.DefaultDaemonNetworkMode().NetworkName()
|
||||
if nConf, ok := container.NetworkSettings.Networks[defaultNetName]; ok {
|
||||
if err := daemon.connectToNetwork(container, defaultNetName, nConf, updateSettings); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
for n, nConf := range container.NetworkSettings.Networks {
|
||||
if n == defaultNetName {
|
||||
continue
|
||||
}
|
||||
if err := daemon.connectToNetwork(container, n, nConf, updateSettings); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue