Setting MinIO Docker Container User to Root
MinIO is a high-performance object storage server compatible with Amazon S3 APIs. It is often used in Docker containers for easy deployment and management. By default, the MinIO Docker container runs with a non-root user, but there might be situations where you need to run the container as the root user. In this article, we will discuss how to set the MinIO Docker container user to root.
Checking the Docker Entry Point Script
The /usr/bin/docker-entrypoint.sh script, which is shipped with the MinIO Docker image, sets up the environment and starts the MinIO server. By default, it runs the server as a non-root user.
To check the entry point script, you can run the following command:
docker run -it minio/minio:latest cat /usr/bin/docker-entrypoint.sh
This will display the contents of the script. You can see that it sets the user to minio before starting the server:
if [ "$MINIO_ACCESS_KEY" ] && [ "$MINIO_SECRET_KEY" ]; then
useradd -r -s /bin/false -g minio $MINIO_SYS_USER || :
chown -R $MINIO_SYS_USER:$MINIO_SYS_GROUP /data || :
exec gosu $MINIO_SYS_USER "$MINIO_OPTS" "$@"
else
echo "MINIO_ACCESS_KEY and MINIO_SECRET_KEY must be set."
exit 1
fi
Setting the User to Root
To set the user to root, you need to modify the entry point script. You can do this by creating a new Dockerfile that extends the MinIO Docker image and overrides the entry point script:
FROM minio/minio:latest
USER root
This Dockerfile sets the user to root and does not specify a new entry point script. When you build the Docker image, it will use the default entry point script from the MinIO Docker image, but with the user set to root.
To build the Docker image, run the following command:
docker build -t myminio:latest .
This will build the Docker image with the user set to root. You can then run the container with the following command:
docker run -p 9000:9000 myminio:latest server /data
This will start the MinIO server in the container, with the user set to root.
- MinIO is a high-performance object storage server compatible with Amazon S3 APIs.
- By default, the MinIO Docker container runs with a non-root user.
- To set the MinIO Docker container user to root, you need to modify the entry point script.
- You can do this by creating a new Dockerfile that extends the MinIO Docker image and overrides the entry point script.
- When you build the Docker image, it will use the default entry point script from the MinIO Docker image, but with the user set to root.