Use IPv6 address
This commit is contained in:
parent
c84378d649
commit
52df1d63fe
4 changed files with 35 additions and 1 deletions
|
@ -77,6 +77,12 @@ func ipv4(ip string) func(*network.EndpointSettings) {
|
|||
}
|
||||
}
|
||||
|
||||
func ipv6(ip string) func(*network.EndpointSettings) {
|
||||
return func(s *network.EndpointSettings) {
|
||||
s.GlobalIPv6Address = ip
|
||||
}
|
||||
}
|
||||
|
||||
func swarmTask(id string, ops ...func(*swarm.Task)) swarm.Task {
|
||||
task := &swarm.Task{
|
||||
ID: id,
|
||||
|
|
|
@ -3511,6 +3511,22 @@ func TestDockerGetIPAddress(t *testing.T) {
|
|||
network: "testnet",
|
||||
expected: "10.11.12.13",
|
||||
},
|
||||
{
|
||||
desc: "one ipv6 network, network label",
|
||||
container: containerJSON(
|
||||
withNetwork("testnet", ipv6("fd00:1:2:3:4::")),
|
||||
),
|
||||
network: "testnet",
|
||||
expected: "fd00:1:2:3:4::",
|
||||
},
|
||||
{
|
||||
desc: "two network ipv4 + ipv6, network label",
|
||||
container: containerJSON(
|
||||
withNetwork("testnet", ipv4("10.11.12.13"), ipv6("fd00:1:2:3:4::")),
|
||||
),
|
||||
network: "testnet",
|
||||
expected: "10.11.12.13",
|
||||
},
|
||||
{
|
||||
desc: "two networks, network label",
|
||||
container: containerJSON(
|
||||
|
|
|
@ -411,10 +411,15 @@ func parseContainer(container dockertypes.ContainerJSON) dockerData {
|
|||
if container.NetworkSettings.Networks != nil {
|
||||
dData.NetworkSettings.Networks = make(map[string]*networkData)
|
||||
for name, containerNetwork := range container.NetworkSettings.Networks {
|
||||
addr := containerNetwork.IPAddress
|
||||
if addr == "" {
|
||||
addr = containerNetwork.GlobalIPv6Address
|
||||
}
|
||||
|
||||
dData.NetworkSettings.Networks[name] = &networkData{
|
||||
ID: containerNetwork.NetworkID,
|
||||
Name: name,
|
||||
Addr: containerNetwork.IPAddress,
|
||||
Addr: addr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue