diff options
Diffstat (limited to 'libpod/networking_linux.go')
-rw-r--r-- | libpod/networking_linux.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 0c9d28701..f53573645 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -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. |