Repository: minio/minio (language: go)

Issue:
MINIO_USERNAME env var not working in latest release (groupadd command not found)
From version: `RELEASE.2023-11-01T18-37-25Z ` and `RELEASE.2023-11-01T01-57-10Z`

## Expected Behavior
User can be added with ENV VARS `MINIO_USERNAME`, `MINIO_GROUPNAME`

## Current Behavior
Attempt to add user with variables ends up with failure:
```
minio_1  | /usr/bin/docker-entrypoint.sh: line 18: groupadd: command not found
minio_1  | /usr/bin/docker-entrypoint.sh: line 21: exec: setpriv: not found
```

## Possible Solution
N/A

## Steps to Reproduce (for bugs)
run following docker-compose.yaml:
```
version: '3'
services:
  minio:
    ### last one working with groupadd / useradd working
    # image: quay.io/minio/minio:RELEASE.2023-10-25T06-33-25Z
    ### latest
    image: quay.io/minio/minio:RELEASE.2023-11-01T18-37-25Z
    volumes:
      - ./data:/data
    ports:
      - 9000:9000
      - 9001:9001
    environment:
      MINIO_ROOT_USER: 'minio_user'
      MINIO_ROOT_PASSWORD: 'minio_password'
      MINIO_ADDRESS: ':9000'
      MINIO_CONSOLE_ADDRESS: ':9001'
      MINIO_USERNAME: 'test-user'
      MINIO_GROUPNAME: 'test-user'
    command: minio server /data
```


## Context
- I'm using image which is adding the user and then running the server with it
## Regression
Yes
(last working version: `RELEASE.2023-10-25T06-33-25Z`)

## Your Environment
- see Steps to reproduce



Discussion / hints:
Correct those commands won't work and are not available anymore.

Please migrate your setup to use docker --user 
This is happening to us as well, we are using "quay.io/minio/minio"
Shouldn't the container just ignore those env variables instead of breaking? Or at least printing an info message that it this approach is not supported anymore?
> This is happening to us as well, we are using "quay.io/minio/minio" Shouldn't the container just ignore those env variables instead of breaking? Or at least printing an info message that it this approach is not supported anymore?

Well yes that can be changed, our point was we wanted to see how many are using such legacy approaches - as there is no way to really know why anyone would be using those things in the first place.

Is it not possible to use `docker run --user` here? 

Fix patch:
diff --git a/.github/workflows/mint/minio-compress-encrypt.yaml b/.github/workflows/mint/minio-compress-encrypt.yaml
index 0ebaacb99b45e..fe1238e80d3d8 100644
--- a/.github/workflows/mint/minio-compress-encrypt.yaml
+++ b/.github/workflows/mint/minio-compress-encrypt.yaml
@@ -16,10 +16,10 @@ x-minio-common: &minio-common
     MINIO_COMPRESSION_ALLOW_ENCRYPTION: "on"
     MINIO_KMS_SECRET_KEY: "my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
   healthcheck:
-    test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
-    interval: 30s
-    timeout: 20s
-    retries: 3
+    test: ["CMD", "mc", "ready", "local"]
+    interval: 5s
+    timeout: 5s
+    retries: 5
 
 # starts 4 docker containers running minio server instances.
 # using nginx reverse proxy, load balancing, you can access
diff --git a/.github/workflows/mint/minio-erasure.yaml b/.github/workflows/mint/minio-erasure.yaml
index e28c137d61563..a3fd6dbc0de21 100644
--- a/.github/workflows/mint/minio-erasure.yaml
+++ b/.github/workflows/mint/minio-erasure.yaml
@@ -13,10 +13,10 @@ x-minio-common: &minio-common
     MINIO_ROOT_PASSWORD: "minio123"
     MINIO_KMS_SECRET_KEY: "my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
   healthcheck:
-    test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
-    interval: 30s
-    timeout: 20s
-    retries: 3
+    test: ["CMD", "mc", "ready", "local"]
+    interval: 5s
+    timeout: 5s
+    retries: 5
 
 # starts 4 docker containers running minio server instances.
 # using nginx reverse proxy, load balancing, you can access
diff --git a/.github/workflows/mint/minio-pools.yaml b/.github/workflows/mint/minio-pools.yaml
index 0a54ca353cbd5..bd79fdae048e6 100644
--- a/.github/workflows/mint/minio-pools.yaml
+++ b/.github/workflows/mint/minio-pools.yaml
@@ -13,10 +13,10 @@ x-minio-common: &minio-common
     MINIO_ROOT_PASSWORD: "minio123"
     MINIO_KMS_SECRET_KEY: "my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
   healthcheck:
-    test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
-    interval: 30s
-    timeout: 20s
-    retries: 3
+    test: ["CMD", "mc", "ready", "local"]
+    interval: 5s
+    timeout: 5s
+    retries: 5
 
 # starts 4 docker containers running minio server instances.
 # using nginx reverse proxy, load balancing, you can access
diff --git a/.gitignore b/.gitignore
index 5d277b10d8165..b226c380b1dbf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,3 +42,4 @@ docs/debugging/healing-bin/healing-bin
 docs/debugging/inspect/inspect
 docs/debugging/pprofgoparser/pprofgoparser
 docs/debugging/reorder-disks/reorder-disks
+docs/debugging/populate-hard-links/populate-hardlinks
diff --git a/dockerscripts/docker-entrypoint.sh b/dockerscripts/docker-entrypoint.sh
index 0e2bdb5a20d19..bd617cb838e3d 100755
--- a/dockerscripts/docker-entrypoint.sh
+++ b/dockerscripts/docker-entrypoint.sh
@@ -8,22 +8,19 @@ if [ "${1}" != "minio" ]; then
 	fi
 fi
 
-# su-exec to requested user, if service cannot run exec will fail.
 docker_switch_user() {
 	if [ -n "${MINIO_USERNAME}" ] && [ -n "${MINIO_GROUPNAME}" ]; then
 		if [ -n "${MINIO_UID}" ] && [ -n "${MINIO_GID}" ]; then
-			groupadd -f -g "$MINIO_GID" "$MINIO_GROUPNAME" &&
-				useradd -u "$MINIO_UID" -g "$MINIO_GROUPNAME" "$MINIO_USERNAME"
+			chroot --userspec=${MINIO_UID}:${MINIO_GID} / "$@"
 		else
-			groupadd -f "$MINIO_GROUPNAME" &&
-				useradd -g "$MINIO_GROUPNAME" "$MINIO_USERNAME"
+			echo "${MINIO_USERNAME}:x:1000:1000:${MINIO_USERNAME}:/:/sbin/nologin" >>/etc/passwd
+			echo "${MINIO_GROUPNAME}:x:1000" >>/etc/group
+			chroot --userspec=${MINIO_USERNAME}:${MINIO_GROUPNAME} / "$@"
 		fi
-		exec setpriv --reuid="${MINIO_USERNAME}" \
-			--regid="${MINIO_GROUPNAME}" --keep-groups "$@"
 	else
 		exec "$@"
 	fi
 }
 
-## Switch to user if applicable.
+## DEPRECATED and unsupported - switch to user if applicable.
 docker_switch_user "$@"
diff --git a/docs/orchestration/docker-compose/docker-compose.yaml b/docs/orchestration/docker-compose/docker-compose.yaml
index f6d8eb467c40a..5f5c0992b9f2c 100644
--- a/docs/orchestration/docker-compose/docker-compose.yaml
+++ b/docs/orchestration/docker-compose/docker-compose.yaml
@@ -11,10 +11,10 @@ x-minio-common: &minio-common
     # MINIO_ROOT_USER: minioadmin
     # MINIO_ROOT_PASSWORD: minioadmin
   healthcheck:
-    test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
-    interval: 30s
-    timeout: 20s
-    retries: 3
+    test: ["CMD", "mc", "ready", "local"]
+    interval: 5s
+    timeout: 5s
+    retries: 5
 
 # starts 4 docker containers running minio server instances.
 # using nginx reverse proxy, load balancing, you can access


Test patch:
diff --git a/buildscripts/upgrade-tests/compose.yml b/buildscripts/upgrade-tests/compose.yml
index 1bdff40f04a89..d70d443d06f2c 100644
--- a/buildscripts/upgrade-tests/compose.yml
+++ b/buildscripts/upgrade-tests/compose.yml
@@ -9,11 +9,6 @@ x-minio-common: &minio-common
   expose:
     - "9000"
     - "9001"
-  healthcheck:
-    test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
-    interval: 30s
-    timeout: 20s
-    retries: 3
 
 # starts 4 docker containers running minio server instances.
 # using nginx reverse proxy, load balancing, you can access