From fdb5ee881813f84b733b842b4d6dba5beba6527c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rodr=C3=ADguez?= Date: Thu, 24 Mar 2022 18:56:15 -0300 Subject: [PATCH] fix: resource host for rootless containers --- dockertest.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dockertest.go b/dockertest.go index 353e4034..b9809143 100644 --- a/dockertest.go +++ b/dockertest.go @@ -69,7 +69,11 @@ func (r *Resource) GetBoundIP(id string) string { return "" } - return m[0].HostIP + ip := m[0].HostIP + if ip == "0.0.0.0" || ip == "" { + return "localhost" + } + return ip } // GetHostPort returns a resource's published port with an address. @@ -84,7 +88,7 @@ func (r *Resource) GetHostPort(portID string) string { } ip := m[0].HostIP - if ip == "0.0.0.0" { + if ip == "0.0.0.0" || ip == "" { ip = "localhost" } return net.JoinHostPort(ip, m[0].HostPort)