mirror of
https://github.com/containers/podman.git
synced 2025-05-20 16:47:39 +08:00
Reformat inspect network settings
Reformat ports of inspect network settings to compatible with docker inspect. Close #5380 Signed-off-by: Qi Wang <qiwan@redhat.com>
This commit is contained in:
@ -587,10 +587,20 @@ func getContainerNetIO(ctr *Container) (*netlink.LinkStatistics, error) {
|
||||
// network.
|
||||
func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, error) {
|
||||
settings := new(define.InspectNetworkSettings)
|
||||
settings.Ports = []ocicni.PortMapping{}
|
||||
settings.Ports = make(map[string][]define.InspectHostPort)
|
||||
if c.config.PortMappings != nil {
|
||||
// TODO: This may not be safe.
|
||||
settings.Ports = c.config.PortMappings
|
||||
for _, port := range c.config.PortMappings {
|
||||
key := fmt.Sprintf("%d/%s", port.ContainerPort, port.Protocol)
|
||||
mapping := settings.Ports[key]
|
||||
if mapping == nil {
|
||||
mapping = []define.InspectHostPort{}
|
||||
}
|
||||
mapping = append(mapping, define.InspectHostPort{
|
||||
HostIP: port.HostIP,
|
||||
HostPort: fmt.Sprintf("%d", port.HostPort),
|
||||
})
|
||||
settings.Ports[key] = mapping
|
||||
}
|
||||
}
|
||||
|
||||
// We can't do more if the network is down.
|
||||
|
Reference in New Issue
Block a user