Repository: minio/minio (language: go)

Issue:
Errors logged at console are not logged when running as container
When starting minio directly from the command line, startup errors are clearly logged.  For example, here's one with a misconfigured DNS name:

```
$ ./minio -version
minio version RELEASE.2024-02-24T17-11-14Z (commit-id=c2b54d92f66ea02642be4ede26f2b7ecac1f2056)
Runtime: go1.21.7 linux/amd64
License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
Copyright: 2015-2024 MinIO, Inc.

$ ./minio server http://bogus-{0...4}.example.com:9000/export
ERROR Invalid command line arguments: lookup bogus-0.example.com on 127.0.0.53:53: no such host
      > Please provide correct combination of local/remote paths
      HINT:
        For more information, please refer to https://min.io/docs/minio/linux/operations/concepts/erasure-coding.html
```

Very clear what went wrong here. 

However, when running under docker, no error is logged:

```
$ docker run -ti minio/minio:RELEASE.2024-02-24T17-11-14Z server http://bogus-{0...4}.example.com:9000/export
[no text]
```

## Expected Behavior

The DNS lookup error should also be logged when Minio is running as a container.

## Current Behavior

When running as a container, Minio logs nothing, and (more incidentally) doesn't terminate.  The non-terminating behavior does make sense to me, as it's being run as a server, although the lack of error logging turned this trivial configuration error into a protracted troubleshooting session.

## Steps to Reproduce (for bugs)

1. Run `docker run -ti minio/minio:RELEASE.2024-02-24T17-11-14Z server http://bogus-{0...4}.example.com:9000/export`

## Context

I was building a Minio cluster as a StatefulSet in Kubernetes and typoed the node FQDN.  

## Your Environment

Minio `RELEASE.2024-02-24T17-11-14Z`

Above example ran on Ubuntu 22.04 on amd64.  Also reproduced in Docker and containerd on Linux amd64.


Discussion / hints:
Will take a look. It must some terminal issue in containers.

Fix patch:
diff --git a/cmd/endpoint.go b/cmd/endpoint.go
index e4e80d07449f0..82b17e43b70e5 100644
--- a/cmd/endpoint.go
+++ b/cmd/endpoint.go
@@ -567,13 +567,6 @@ func (endpoints Endpoints) GetAllStrings() (all []string) {
 func hostResolveToLocalhost(endpoint Endpoint) bool {
 	hostIPs, err := getHostIP(endpoint.Hostname())
 	if err != nil {
-		// Log the message to console about the host resolving
-		reqInfo := (&logger.ReqInfo{}).AppendTags(
-			"host",
-			endpoint.Hostname(),
-		)
-		ctx := logger.SetReqInfo(GlobalContext, reqInfo)
-		logger.LogOnceIf(ctx, err, endpoint.Hostname(), logger.ErrorKind)
 		return false
 	}
 	var loopback int
@@ -867,7 +860,7 @@ func (p PoolEndpointList) UpdateIsLocal() error {
 								))
 							ctx := logger.SetReqInfo(GlobalContext,
 								reqInfo)
-							logger.LogOnceIf(ctx, err, endpoint.Hostname(), logger.ErrorKind)
+							logger.LogOnceIf(ctx, fmt.Errorf("Unable to resolve DNS for %s: %w", endpoint, err), endpoint.Hostname(), logger.ErrorKind)
 						}
 					} else {
 						resolvedList[endpoint] = true
diff --git a/cmd/server-main.go b/cmd/server-main.go
index 6066e219b4483..9001dc02bebf6 100644
--- a/cmd/server-main.go
+++ b/cmd/server-main.go
@@ -651,6 +651,15 @@ func serverMain(ctx *cli.Context) {
 
 	setDefaultProfilerRates()
 
+	// Initialize globalConsoleSys system
+	bootstrapTrace("newConsoleLogger", func() {
+		globalConsoleSys = NewConsoleLogger(GlobalContext)
+		logger.AddSystemTarget(GlobalContext, globalConsoleSys)
+
+		// Set node name, only set for distributed setup.
+		globalConsoleSys.SetNodeName(globalLocalNodeName)
+	})
+
 	// Always load ENV variables from files first.
 	loadEnvVarsFromFiles()
 
@@ -672,15 +681,6 @@ func serverMain(ctx *cli.Context) {
 	// the config file if not defined, set the default one.
 	loadRootCredentials()
 
-	// Initialize globalConsoleSys system
-	bootstrapTrace("newConsoleLogger", func() {
-		globalConsoleSys = NewConsoleLogger(GlobalContext)
-		logger.AddSystemTarget(GlobalContext, globalConsoleSys)
-
-		// Set node name, only set for distributed setup.
-		globalConsoleSys.SetNodeName(globalLocalNodeName)
-	})
-
 	// Perform any self-tests
 	bootstrapTrace("selftests", func() {
 		bitrotSelfTest()


Test patch: