Only warn about missing docker network when network_mode is not host or container
This commit is contained in:
parent
77509b0913
commit
ac9d88e5a2
1 changed files with 6 additions and 1 deletions
|
@ -310,6 +310,7 @@ func (p *Provider) getIPPort(ctx context.Context, container dockerData, serverPo
|
||||||
func (p Provider) getIPAddress(ctx context.Context, container dockerData) string {
|
func (p Provider) getIPAddress(ctx context.Context, container dockerData) string {
|
||||||
logger := log.FromContext(ctx)
|
logger := log.FromContext(ctx)
|
||||||
|
|
||||||
|
netNotFound := false
|
||||||
if container.ExtraConf.Docker.Network != "" {
|
if container.ExtraConf.Docker.Network != "" {
|
||||||
settings := container.NetworkSettings
|
settings := container.NetworkSettings
|
||||||
if settings.Networks != nil {
|
if settings.Networks != nil {
|
||||||
|
@ -318,7 +319,8 @@ func (p Provider) getIPAddress(ctx context.Context, container dockerData) string
|
||||||
return network.Addr
|
return network.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Warnf("Could not find network named '%s' for container '%s'! Maybe you're missing the project's prefix in the label? Defaulting to first available network.", container.ExtraConf.Docker.Network, container.Name)
|
netNotFound = true
|
||||||
|
logger.Debugf("Could not find network named %q for container %q. Maybe you're missing the project's prefix in the label?", container.ExtraConf.Docker.Network, container.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +369,9 @@ func (p Provider) getIPAddress(ctx context.Context, container dockerData) string
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, network := range container.NetworkSettings.Networks {
|
for _, network := range container.NetworkSettings.Networks {
|
||||||
|
if netNotFound {
|
||||||
|
logger.Warnf("Defaulting to first available network (%q) for container %q.", network, container.Name)
|
||||||
|
}
|
||||||
return network.Addr
|
return network.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue