Minio MC Docker Cli Setup

guides/minio/minio-docker.jpg

A guide on How to setup Minio MC CLI tool Wrapped in docker!


Minio Docs

Tools Required

Docker

Minio Image
minio/mc:latest

Setup bashrc or zshrc

~/.bashrc or ~/.zshrc

1alias mc="sudo docker run --rm --name mc -it -v /home/$(whoami)/.mc/config.json:/root/.mc/config.json  minio/mc $@"

Setup ~/.mc/config.json

First we will create a folder called .mc

1mkdir ~/.mc
2
3touch ~/.mc/config.json

Edit config.json

 1{
 2        "version": "10",
 3        "aliases": {
 4                "MINIO_ALIAS": {
 5                        "url": "https://YOUR_MINIO_URL",
 6                        "accessKey": "MINIO_USERNAME",
 7                        "secretKey": "MINIO_PASSWORD",
 8                        "api": "s3v4",
 9                        "path": "auto"
10                },
11                "gcs": {
12                        "url": "https://storage.googleapis.com",
13                        "accessKey": "YOUR-ACCESS-KEY-HERE",
14                        "secretKey": "YOUR-SECRET-KEY-HERE",
15                        "api": "S3v2",
16                        "path": "dns"
17                },
18                "local": {
19                        "url": "http://localhost:9000",
20                        "accessKey": "",
21                        "secretKey": "",
22                        "api": "S3v4",
23                        "path": "auto"
24                },
25                "play": {
26                        "url": "https://play.min.io",
27                        "accessKey": "Q3AM3UQ867SPQQA43P2F",
28                        "secretKey": "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
29                        "api": "S3v4",
30                        "path": "auto"
31                },
32                "s3": {
33                        "url": "https://s3.amazonaws.com",
34                        "accessKey": "YOUR-ACCESS-KEY-HERE",
35                        "secretKey": "YOUR-SECRET-KEY-HERE",
36                        "api": "S3v4",
37                        "path": "dns"
38                }
39        }
40}

Get Required Fields From Minio

  • 1 - Log into your minio server and we are going to create a service account

  • 2 - Click on the lefthand side

Identity -> Users

  • 3 - Click on your name and go to Service Accounts

  • 4 - Create a New Service Account

The default Values can be used or you can edit the fields to create your own

I reccomend at least Renaming the Access Key So its easy to determine what the account is in logs

SA

Populate config.json

lets set the alias as mantis and add the fields

1"mantis": {
2    "url": "https://YOUR_MINIO_URL",
3    "accessKey": "minio-mc",
4    "secretKey": "qTCxobQsgX14cgg2IkmTiGLaiV8QNZ1q",
5    "api": "s3v4",
6    "path": "auto"
7},

Test our Docker Cli Tool

if you arent in a new terminal lets source our bashrc or zshrc so we have the updated alias

1source ~/.bashrc 
2
3source ~/.zshrc

test list buckets

1mc ls mantis

output

test add a bucket

1mc mb mantis/test

output

mc: Successfully created /root/.mc/share.

mc: Initialized share uploads /root/.mc/share/uploads.json file.

mc: Initialized share downloads /root/.mc/share/downloads.json file.

Removed brock/test successfully.

test remove bucket

1mc rb mantis/test

output

mc: Successfully created /root/.mc/share.

mc: Initialized share uploads /root/.mc/share/uploads.json file.

mc: Initialized share downloads /root/.mc/share/downloads.json file.

Removed brock/test successfully.

Done

Cli Is now setup