|
@@ -11,6 +11,7 @@ import (
|
|
|
"github.com/docker/docker/api/types/versions/v1p20"
|
|
|
"github.com/docker/docker/container"
|
|
|
"github.com/docker/docker/daemon/network"
|
|
|
+ "github.com/docker/go-connections/nat"
|
|
|
)
|
|
|
|
|
|
// ContainerInspect returns low-level information about a
|
|
@@ -45,7 +46,8 @@ func (daemon *Daemon) ContainerInspectCurrent(name string, size bool) (*types.Co
|
|
|
apiNetworks := make(map[string]*networktypes.EndpointSettings)
|
|
|
for name, epConf := range container.NetworkSettings.Networks {
|
|
|
if epConf.EndpointSettings != nil {
|
|
|
- apiNetworks[name] = epConf.EndpointSettings
|
|
|
+ // We must make a copy of this pointer object otherwise it can race with other operations
|
|
|
+ apiNetworks[name] = epConf.EndpointSettings.Copy()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -57,7 +59,6 @@ func (daemon *Daemon) ContainerInspectCurrent(name string, size bool) (*types.Co
|
|
|
HairpinMode: container.NetworkSettings.HairpinMode,
|
|
|
LinkLocalIPv6Address: container.NetworkSettings.LinkLocalIPv6Address,
|
|
|
LinkLocalIPv6PrefixLen: container.NetworkSettings.LinkLocalIPv6PrefixLen,
|
|
|
- Ports: container.NetworkSettings.Ports,
|
|
|
SandboxKey: container.NetworkSettings.SandboxKey,
|
|
|
SecondaryIPAddresses: container.NetworkSettings.SecondaryIPAddresses,
|
|
|
SecondaryIPv6Addresses: container.NetworkSettings.SecondaryIPv6Addresses,
|
|
@@ -66,6 +67,12 @@ func (daemon *Daemon) ContainerInspectCurrent(name string, size bool) (*types.Co
|
|
|
Networks: apiNetworks,
|
|
|
}
|
|
|
|
|
|
+ ports := make(nat.PortMap, len(container.NetworkSettings.Ports))
|
|
|
+ for k, pm := range container.NetworkSettings.Ports {
|
|
|
+ ports[k] = pm
|
|
|
+ }
|
|
|
+ networkSettings.NetworkSettingsBase.Ports = ports
|
|
|
+
|
|
|
return &types.ContainerJSON{
|
|
|
ContainerJSONBase: base,
|
|
|
Mounts: mountPoints,
|