Skip to content

Commit

Permalink
Set network ID if available during container inspect. Fixes container…
Browse files Browse the repository at this point in the history
…s#24910

Signed-off-by: Florian Apolloner <[email protected]>
  • Loading branch information
apollo13 committed Jan 6, 2025
1 parent d3cd509 commit 833f018
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libpod/networking_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,13 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
if len(networks) > 0 {
settings.Networks = make(map[string]*define.InspectAdditionalNetwork, len(networks))
for net, opts := range networks {
netID := net
network, err := c.runtime.network.NetworkInspect(net)
if err == nil {
netID = network.ID
}
cniNet := new(define.InspectAdditionalNetwork)
cniNet.NetworkID = net
cniNet.NetworkID = netID
cniNet.Aliases = opts.Aliases
settings.Networks[net] = cniNet
}
Expand Down Expand Up @@ -272,9 +277,14 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
settings.Networks = make(map[string]*define.InspectAdditionalNetwork, len(networks))

for name, opts := range networks {
netID := name
network, err := c.runtime.network.NetworkInspect(name)
if err == nil {
netID = network.ID
}
result := netStatus[name]
addedNet := new(define.InspectAdditionalNetwork)
addedNet.NetworkID = name
addedNet.NetworkID = netID
addedNet.Aliases = opts.Aliases
addedNet.InspectBasicNetworkConfig = resultToBasicNetworkConfig(result)

Expand Down

0 comments on commit 833f018

Please sign in to comment.