Merge pull request #12328 from serverwentdown/fix-compat-ipaddress

compat: Add subnet mask behind IP address to match Docker API
This commit is contained in:
Daniel J Walsh authored and GitHub committed 2021-11-23 10:39:32 -05:00
commit 400ccc6205
2 files changed
+39 -3

No files matched your search

+12 -3
View File
@@ -2,6 +2,7 @@ package compat
import (
"encoding/json"
"fmt"
"net"
"net/http"
@@ -69,12 +70,20 @@ func convertLibpodNetworktoDockerNetwork(runtime *libpod.Runtime, network nettyp
return nil, err
}
if netData, ok := data.NetworkSettings.Networks[network.Name]; ok {
ipv4Address := ""
if netData.IPAddress != "" {
ipv4Address = fmt.Sprintf("%s/%d", netData.IPAddress, netData.IPPrefixLen)
}
ipv6Address := ""
if netData.GlobalIPv6Address != "" {
ipv6Address = fmt.Sprintf("%s/%d", netData.GlobalIPv6Address, netData.GlobalIPv6PrefixLen)
}
containerEndpoint := types.EndpointResource{
Name: netData.NetworkID,
Name: con.Name(),
EndpointID: netData.EndpointID,
MacAddress: netData.MacAddress,
IPv4Address: netData.IPAddress,
IPv6Address: netData.GlobalIPv6Address,
IPv4Address: ipv4Address,
IPv6Address: ipv6Address,
}
containerEndpoints[con.ID()] = containerEndpoint
}