summaryrefslogtreecommitdiff
path: root/libpod/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/util.go')
-rw-r--r--libpod/util.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/libpod/util.go b/libpod/util.go
index 3b32fb264..ed5c4e6c6 100644
--- a/libpod/util.go
+++ b/libpod/util.go
@@ -295,8 +295,8 @@ func writeHijackHeader(r *http.Request, conn io.Writer) {
}
// Convert OCICNI port bindings into Inspect-formatted port bindings.
-func makeInspectPortBindings(bindings []ocicni.PortMapping) map[string][]define.InspectHostPort {
- portBindings := make(map[string][]define.InspectHostPort)
+func makeInspectPortBindings(bindings []ocicni.PortMapping, expose map[uint16][]string) map[string][]define.InspectHostPort {
+ portBindings := make(map[string][]define.InspectHostPort, len(bindings))
for _, port := range bindings {
key := fmt.Sprintf("%d/%s", port.ContainerPort, port.Protocol)
hostPorts := portBindings[key]
@@ -309,6 +309,15 @@ func makeInspectPortBindings(bindings []ocicni.PortMapping) map[string][]define.
})
portBindings[key] = hostPorts
}
+ // add exposed ports without host port information to match docker
+ for port, protocols := range expose {
+ for _, protocol := range protocols {
+ key := fmt.Sprintf("%d/%s", port, protocol)
+ if _, ok := portBindings[key]; !ok {
+ portBindings[key] = nil
+ }
+ }
+ }
return portBindings
}