Search

Suggested keywords:
  • Java
  • Docker
  • Git
  • React
  • NextJs
  • Spring boot
  • Laravel

How to Setup and Configure Minio with Docker

  • Share this:

post-title

Minio is a high-performance, S3-compatible object storage solution that's perfect for storing unstructured data such as photos, videos, log files, and backups. Deploying Minio with Docker simplifies the setup and management process, making it easier to scale and maintain. A step-by-step guide to using Minio with Docker, covering installation, configuration, and basic operations.

This article is part of Mino tutorial series.

 

Prerequisites

Before you begin, ensure you have the following installed on your machine:

  • Docker
  • Docker Compose (optional but recommended)

 

Setting up Docker with Minio

Step 1: Pulling the Minio Docker Image

The first step in setting up Minio with Docker is to pull the official Minio Docker image from Docker Hub.

docker pull minio/minio

 

Step 2: Running Minio Container

To start a Minio container, you need to specify the storage directory and the access credentials. Use the following command to run Minio:

docker run -d -p 9000:9000 --name minio \
  -e "MINIO_ROOT_USER=minioadmin" \
  -e "MINIO_ROOT_PASSWORD=minioadmin123" \
  -v /path/to/data:/data \
  minio/minio server /data
  • -d: Run the container in detached mode.
  • -p 9000:9000: Map port 9000 of the host to port 9000 of the container.
  • --name minio: Assign the container a name for easier management.
  • -e "MINIO_ROOT_USER=minioadmin" and -e "MINIO_ROOT_PASSWORD=minioadmin123": Set the root username and password.
  • -v /path/to/data:/data: Mount the host directory to the container's data directory.

 

Step 3: Accessing Minio

By navigating to http://localhost:9000 in your web browser, you can access the Minio web interface once the container is running. Log in using the credentials specified in the Docker run command.

 

Step 4: Using Docker Compose for Minio

Docker Compose makes it easier to manage multi-container Docker applications. Below is a sample docker-compose.yml file for running Minio:

version: '3.7'

services:
  minio:
    image: minio/minio
    container_name: minio
    ports:
      - "9000:9000"
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin123
    volumes:
      - /path/to/data:/data
    command: server /data

To start the Minio service using Docker Compose, run the following commands:

docker-compose up -d

This command will start Minio in detached mode.

 

Step 5: Managing Minio

With Minio running in a Docker container, you can perform various operations such as creating buckets, uploading files, and setting policies through the web interface or using the Minio Client (mc).

 

Installing Minio Client:

wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
sudo mv mc /usr/local/bin/

 

Configuring Minio Client:

mc alias set myminio http://localhost:9000 minioadmin minioadmin123

 

Creating a Bucket:

mc mb myminio/mybucket

 

Uploading a File:

mc cp myfile.txt myminio/mybucket

 

Listing Files in a Bucket:

mc ls myminio/mybucket

 

Step 6: Scaling Minio with Docker

Minio supports distributed mode, which can be achieved using Docker Compose by adding multiple Minio instances. Below is an example of a docker-compose.yml file for a distributed Minio setup:

version: '3.7'

services:
  minio1:
    image: minio/minio
    volumes:
      - /mnt/data1:/data
    ports:
      - "9001:9000"
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin123
    command: server http://minio1/data http://minio2/data http://minio3/data http://minio4/data

  minio2:
    image: minio/minio
    volumes:
      - /mnt/data2:/data
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin123
    command: server http://minio1/data http://minio2/data http://minio3/data http://minio4/data

  minio3:
    image: minio/minio
    volumes:
      - /mnt/data3:/data
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin123
    command: server http://minio1/data http://minio2/data http://minio3/data http://minio4/data

  minio4:
    image: minio/minio
    volumes:
      - /mnt/data4:/data
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin123
    command: server http://minio1/data http://minio2/data http://minio3/data http://minio4/data

Run the following command to start the distributed Minio setup:

docker-compose up -d

 

Conclusion

Using Minio with Docker simplifies the deployment and management of scalable, high-performance object storage. Whether you are running a single instance for development or a distributed setup for production, Docker and Docker Compose offer the flexibility and convenience needed to manage Minio effectively. Following these steps will help you take advantage of Minio's robust features and get started.

Muthu Annamalai

About author
Technical Writer | Pre-Final Year Student | Code & Community | Developer who works everyday to improve himself.