Use of container.HostConfig.NetworkMode to detect host mode
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
6fd8979754
commit
b1ecb1f61f
2 changed files with 32 additions and 6 deletions
|
@ -270,12 +270,14 @@ func (provider *Docker) getIPAddress(container dockertypes.ContainerJSON) string
|
|||
}
|
||||
}
|
||||
}
|
||||
for networkName, network := range container.NetworkSettings.Networks {
|
||||
// If net==host, quick n' dirty, we return 127.0.0.1
|
||||
// This will work locally, but will fail with swarm.
|
||||
if "host" == networkName {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
|
||||
// If net==host, quick n' dirty, we return 127.0.0.1
|
||||
// This will work locally, but will fail with swarm.
|
||||
if container.HostConfig != nil && "host" == container.HostConfig.NetworkMode {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
|
||||
for _, network := range container.NetworkSettings.Networks {
|
||||
return network.IPAddress
|
||||
}
|
||||
return ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue