Skip to content

Commit 230039c

Browse files
authored
fix: resource host for rootless containers (#348)
1 parent 23d5405 commit 230039c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dockertest.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ func (r *Resource) GetBoundIP(id string) string {
6969
return ""
7070
}
7171

72-
return m[0].HostIP
72+
ip := m[0].HostIP
73+
if ip == "0.0.0.0" || ip == "" {
74+
return "localhost"
75+
}
76+
return ip
7377
}
7478

7579
// GetHostPort returns a resource's published port with an address.
@@ -84,7 +88,7 @@ func (r *Resource) GetHostPort(portID string) string {
8488
}
8589

8690
ip := m[0].HostIP
87-
if ip == "0.0.0.0" {
91+
if ip == "0.0.0.0" || ip == "" {
8892
ip = "localhost"
8993
}
9094
return net.JoinHostPort(ip, m[0].HostPort)

0 commit comments

Comments
 (0)