mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
daemon: Daemon.setupLinkedContainers: don't fetch linked containers if not used
This function was unconditionally trying to fetch linked container, even if the container was not using the default bridge (the only network that supports legacy links). Also removing the intermediate variable, as daemon.children, through daemon.linkindex.children already returns a variable with a copy of these links. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -30,15 +30,13 @@ import (
|
||||
)
|
||||
|
||||
func (daemon *Daemon) setupLinkedContainers(ctr *container.Container) ([]string, error) {
|
||||
var env []string
|
||||
children := daemon.children(ctr)
|
||||
|
||||
bridgeSettings := ctr.NetworkSettings.Networks[network.DefaultNetwork]
|
||||
if bridgeSettings == nil || bridgeSettings.EndpointSettings == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
for linkAlias, child := range children {
|
||||
var env []string
|
||||
for linkAlias, child := range daemon.children(ctr) {
|
||||
if !child.IsRunning() {
|
||||
return nil, fmt.Errorf("Cannot link to a non running container: %s AS %s", child.Name, linkAlias)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user