mirror of
https://github.com/containers/podman.git
synced 2025-10-25 18:25:59 +08:00
Include CNI networks in inspect output when not running
We were only including the CNI Network fields in the output of `podman inspect` when the container was not running. It's simple enough to fix (populate with empty structs, since we can't fill anything without a CNI response to get IP address assigned, etc). This is necessary for Docker compatibility. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
@ -828,6 +828,17 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
|
||||
|
||||
// We can't do more if the network is down.
|
||||
if c.state.NetNS == nil {
|
||||
// We still want to make dummy configurations for each CNI net
|
||||
// the container joined.
|
||||
if len(c.config.Networks) > 0 {
|
||||
settings.Networks = make(map[string]*define.InspectAdditionalNetwork, len(c.config.Networks))
|
||||
for _, net := range c.config.Networks {
|
||||
cniNet := new(define.InspectAdditionalNetwork)
|
||||
cniNet.NetworkID = net
|
||||
settings.Networks[net] = cniNet
|
||||
}
|
||||
}
|
||||
|
||||
return settings, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user