Running S3 Object Storage Locally with MinIO

Prerequisites

You can code along with this tutorial on any operating system If you have Docker and docker-compose.

Installation

Install MinIO using Homebrew

Homebrew is the fastest way to get MinIO up and running if you have a Mac. If you don’t have a Mac, follow the Docker tutorial below.

brew install minio/stable/minio
brew install minio/stable/mc

Create a MinIO server instance

Creating a new server instance is quite simple. Run the command below in a terminal.

minio server /path/to/some/dir
export ACCESS_KEY=admin
export ACCESS_SECRET=password
minio server /path/to/some/dir

Installing MinIO using Docker

This is my favoured approach. I have a Synology NAS, which I use to host Docker Containers and more. For MinIO it gives me plenty of storage space and access to S3 across my network.

docker-compose up
http://localhost:9001
http://localhost:9002
http://localhost:9003
http://localhost:9004

Other operating systems

The MinIO docker hub repo contains further details for installing MinIO. It also covers other operating systems such as Linux and Windows. https://registry.hub.docker.com/r/minio/minio/

The MinIO Web Interface

This section of the tutorial assumes you used homebrew to install MinIO. If you used Docker, simply change the port number 9000 to 9001

MinIO web interface UI Login Screen
MinIO Web UI login screen
MinIO Web Browser Interface
MinIO Web Browser Interface
MinIO Web Browser after creating bucket and file
MinIO Web Browser after creating a bucket and file

mc CLI tool

Let’s take a look at the MinIO CLI tool, mc

Creating an alias

Before we can use mc, we need to create an alias to the MinIO server endpoint.

mc alias set localS3 http://192.168.30.100:9000

Listing buckets and files in the CLI

Keep the server running and open another terminal window.

mc ls localS3
Listing buckets
Listing buckets
mc ls localS3/testing
Listing files inside buckets
Listing files inside buckets

Deleting files and buckets with mc

The two commands used to remove buckets and files are

  • rb : Removes a bucket
mc rm locals3/testing/bensound-goinghigher.mp3
removing a file from a bucket
removing a file from a bucket
mc rb localS3/testing
Removing a bucket
removing a bucket

Further mc commands and built in help

There is a lot more you can do with mc the built-in documentation is really helpful. To access the docs simply type mc —-help to get help on a specific command like ls type mc ls --help

Using AWS-SDK with MinIO

As MinIO has an API compatible with AWS, it’s possible to use the AWS-SDK in your code. Even if your planning to use MinIO in production, using the AWS-SDK allows for a seamless transition to AWS at a future date.

mkdir minio_demo
cd minio_demo
npm init -y
npm install aws-sdk
node app.js
The result from running the demo node app
The result from running the demo node app

Summary

You have learned that MinIO is an Object Storage server with an AWS compatible API.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store