Merge pull request #24164 from mheon/host_network_no_expose_in_ports

Exposed ports are only included when not --net=host
This commit is contained in:
openshift-merge-bot[bot]
2024-10-04 17:03:40 +00:00
committed by GitHub
2 changed files with 17 additions and 8 deletions

View File

@@ -211,7 +211,11 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver
return nil, err
}
data.NetworkSettings = networkConfig
addInspectPortsExpose(c.config.ExposedPorts, data.NetworkSettings.Ports)
// Ports in NetworkSettings includes exposed ports for network modes that are not host,
// and not container.
if !(c.config.NetNsCtr != "" || c.NetworkMode() == "host") {
addInspectPortsExpose(c.config.ExposedPorts, data.NetworkSettings.Ports)
}
inspectConfig := c.generateInspectContainerConfig(ctrSpec)
data.Config = inspectConfig