Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions libpod/networking_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ func resultToBasicNetworkConfig(result types.StatusBlock) define.InspectBasicNet
if config.IPAddress == "" {
config.IPAddress = netAddress.IPNet.IP.String()
config.IPPrefixLen = size
config.Gateway = netAddress.Gateway.String()
if netAddress.Gateway != nil {
config.Gateway = netAddress.Gateway.String()
}
} else {
config.SecondaryIPAddresses = append(config.SecondaryIPAddresses, define.Address{Addr: netAddress.IPNet.IP.String(), PrefixLength: size})
}
Expand All @@ -334,7 +336,9 @@ func resultToBasicNetworkConfig(result types.StatusBlock) define.InspectBasicNet
if config.GlobalIPv6Address == "" {
config.GlobalIPv6Address = netAddress.IPNet.IP.String()
config.GlobalIPv6PrefixLen = size
config.IPv6Gateway = netAddress.Gateway.String()
if netAddress.Gateway != nil {
config.IPv6Gateway = netAddress.Gateway.String()
}
} else {
config.SecondaryIPv6Addresses = append(config.SecondaryIPv6Addresses, define.Address{Addr: netAddress.IPNet.IP.String(), PrefixLength: size})
}
Expand Down
12 changes: 12 additions & 0 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,18 @@ t POST containers/${cid_top}/start 204
t GET containers/${cid_top}/json 200 \
.State.Status="running"

# check that gateway is empty not "<nil>", https://github.com/containers/podman/issues/28705
podman network create testnet --internal --disable-dns
podman run --name testcon --network testnet -d $IMAGE top

t GET containers/testcon/json 200 \
.NetworkSettings.Networks.testnet.Gateway="" \
.NetworkSettings.Networks.testnet.IPAddress~10\..* \
.NetworkSettings.Networks.testnet.IPPrefixLen=24

podman rm -f -t0 testcon
podman network rm testnet

# 0 means unlimited, need same with docker
t GET containers/json?limit=0 200 \
.[0].Id~[0-9a-f]\\{64\\}
Expand Down