diff --git a/dockerscripts/healthcheck.go b/dockerscripts/healthcheck.go index 02d471062..ec0674df9 100755 --- a/dockerscripts/healthcheck.go +++ b/dockerscripts/healthcheck.go @@ -39,6 +39,7 @@ const ( healthPath = "/minio/health/live" timeout = time.Duration(30 * time.Second) tcp = "tcp" + anyIP = ":::" ) // returns container boot time by finding @@ -69,17 +70,15 @@ func findEndpoint() (string, error) { scanner := bufio.NewScanner(stdout) scanner.Split(bufio.ScanLines) // MinIO works on TCP and it is supposed to be - // the only process listening on a port inside - // container. So we take the first row of netstat - // output (that has tcp) and assume that is the - // MinIO server port. + // the only process listening on a port on any IP address + // (on :::) inside container. // Since MinIO is running as non-root user, we can - // no longer depend on the PID/Program name column + // not depend on the PID/Program name column // of netstat output for scanner.Scan() { - if strings.Contains(scanner.Text(), tcp) { - line := scanner.Text() - newLine := strings.Replace(line, ":::", "127.0.0.1:", 1) + line := scanner.Text() + if strings.Contains(line, tcp) && strings.Contains(line, anyIP) { + newLine := strings.Replace(line, anyIP, "127.0.0.1:", 1) fields := strings.Fields(newLine) // index 3 in the row has the Local address // find the last index of ":" - address will