diff options
author | Ambrose Chua <ambrose@hey.com> | 2021-11-17 20:07:58 +0800 |
---|---|---|
committer | Ambrose Chua <ambrose@hey.com> | 2021-11-20 21:00:38 +0800 |
commit | ab56a7c4b75e3f4c083da420cc9b7a85be4303c8 (patch) | |
tree | 1d05961b8a50d295725e80bf5cf364c628ac3c19 /pkg/api/handlers | |
parent | a6976c9ca8346331001dfade295173ad1482c2f6 (diff) | |
download | podman-ab56a7c4b75e3f4c083da420cc9b7a85be4303c8.tar.gz podman-ab56a7c4b75e3f4c083da420cc9b7a85be4303c8.tar.bz2 podman-ab56a7c4b75e3f4c083da420cc9b7a85be4303c8.zip |
compat: Add subnet mask behind IP address to match Docker API
Signed-off-by: Ambrose Chua <ambrose@hey.com>
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index dd28f6deb..8aab29658 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -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 } |