Skip to content

Commit

Permalink
naive fix for #25 (#26)
Browse files Browse the repository at this point in the history
Thanks!
  • Loading branch information
jpicht authored Jun 30, 2022
1 parent af45ca7 commit 5660bed
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dockerdiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,18 @@ func (dd *DockerDiscovery) getContainerAddress(container *dockerapi.Container) (
}
}

network, ok := container.NetworkSettings.Networks[networkMode]
var (
network dockerapi.ContainerNetwork
ok = false
)

if hasNetName {
log.Printf("[docker] network name %s specified (%s)", netName, container.ID[:12])
network, ok = container.NetworkSettings.Networks[netName]
} else if len(container.NetworkSettings.Networks) == 1 {
for netName, network = range container.NetworkSettings.Networks {
ok = true
}
}

if !ok { // sometime while "network:disconnect" event fire
Expand Down

0 comments on commit 5660bed

Please sign in to comment.