Skip to content

Instantly share code, notes, and snippets.

@frengky
Last active August 22, 2023 02:41
Show Gist options
  • Save frengky/353ac12dca30c99935bf4e5c13820c83 to your computer and use it in GitHub Desktop.
Save frengky/353ac12dca30c99935bf4e5c13820c83 to your computer and use it in GitHub Desktop.
This is a quick start guide to run a S3 compatible open source object storage server using MinIO

Local S3 Object Storage

This is a quick start guide to run a S3 compatible open source object storage server using MinIO.

References

The docker image used in this guide:

Objectives

S3 compatible object storage server endpoint on http://minio:9000 with access key minio and secret miniosecret contains bucket mybucket which is accessible from our docker network development

Quick Start Guide

1. Run MinIO server on port 9000

$ docker run -d --name minio -v "minio-data:/data" --network development -p 9000:9000 -e MINIO_ACCESS_KEY=minio -e MINIO_SECRET_KEY=miniosecret minio/minio server /data

Point your web browser to http://your-docker-host:9000 and ensure MinIO server has started successfully.

2. Prepare the MinIO client

Create a mc command alias to run the MinIO client via docker image minio/mc:

$ alias mc='docker run -it --rm --name mc --network development -v "minio-mc-root:/root" minio/mc $@'

Add new alias pointed to our previous created MinIO server

$ mc alias set minio http://minio:9000 minio miniosecret

Confirm the server alias is added correctly

$ mc alias list

Check our server status

$ mc admin info minio

Find more command with mc help

3. Create a bucket

Create a new bucket called mybucket

$ mc mb minio/mybucket 

Confirm the bucket was created

$ mc ls minio

4. Test accessing our MinIO object storage using AWS CLI

Create the aws command alias first

$ alias aws='docker run -it --rm --name aws-cli --network development -v "aws-cli-root:/root" amazon/aws-cli --endpoint-url http://minio:9000 $@'

Configure the aws cli using interactive setup

$ aws configure

Enter this while asked:

Name Value
Access Key minio
Secret miniosecret
Default Region us-east-1
Default Output json

Finally, list our bucket

$ aws s3 ls

Backup the objects to our local directory

$ aws s3 sync s3://mybucket /data

Note: this command will also delete local file that not exists on the storage server

$ aws s3 cp s3://mybucket /data --recursive

Note: this command will download recursively including the folder

5. Access the uploaded object via URL

Set the bucket policy public

$ mc anonymous set public minio/mybucket

Now should be able to access the object via URL http://minio:9000/mybucket/[object_name]

6. Prevent directory listing

$ mc anonymous set none myminio/file
$ mc anonymous set download myminio/file/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment