Skip to content

Commit 13d7074

Browse files
committed
fix: not using network id for gateway
1 parent 38a7b6f commit 13d7074

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/client/host.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,14 @@ func (c *Client) HostIPFromContainers(ctx context.Context, netId *string) (net.I
7575
return nil, fmt.Errorf("no output from container %s", cont.ID)
7676
}
7777
ipAddrStr = strings.TrimSpace(string(ipAddrByteStr))
78-
} else {
78+
} else if netId == nil {
7979
ipAddrStr = inspect.NetworkSettings.Gateway
80+
} else {
81+
endpoint, ok := inspect.NetworkSettings.Networks[*netId]
82+
if !ok {
83+
return nil, fmt.Errorf("network %s not found in container %s", *netId, cont.ID)
84+
}
85+
ipAddrStr = endpoint.Gateway
8086
}
8187

8288
ipAddr := net.ParseIP(ipAddrStr)

0 commit comments

Comments
 (0)