How to Create an Object Storage Bucket with MinIO Object Storage

MinIO is a great tool to have if you need to use object storage for just about any type of need. For example, you could create object storage to be used with your Kubernetes deployments. Imagine having the combination of scalability with both container deployments and object storage. The sky is, as they say, the limits.
I’ve already walked you through the process of deploying MinIO on Rocky Linux, which can be done on local machines or even third-party cloud-hosted systems. Regardless of where you deploy MinIO, you’ll need to create object buckets that will be used to store all that data (such as images, videos, documents, and more). This tutorial will show you how.
One very handy aspect of MinIO is that it allows you to create object storage buckets from both the Web UI and the command line. That means you can take care of this process, even if you don’t have a web browser handy and all you can do is SSH into that MinIO server. So, whether you prefer a GUI or the CLI (Command Line Interface), you’re good to go with MinIO.
Let me show you how this is done.
Requirements
The only thing you’ll need for this is a running instance of MinIO and an admin user account to log into. That’s it. Let’s get this storage show on the road.
Creating a storage bucket from the GUI
First, we’ll deal with the GUI side of things. Log in to your MinIO instance by pointing your browser to http://SERVER:9001 (where SERVER is either the domain or IP address of the hosting server). You’ll log in with the username “admin” and the password you created for the user during installation.
Upon successful login, you’ll be prompted to create your first Storage Bucket (Figure 1).
-
Figure 1: MinIO has been installed and is ready to create the first bucket.
Click Create Bucket. In the resulting window (Figure 2), you must give the bucket a name (such as tnstest).
-
Figure 2: Creating a new storage bucket in MinIO.
After giving the bucket a name, you must then decide the options you want to enable, which are:
- Versioning makes it possible to keep multiple versions of an object under the same key.
- Object Locking prevents anyone from deleting an object. This option can only be enabled when you first create the bucket.
- Quota limits the amount of data that can be stored in the bucket.
When enabling some of the above options, you’ll notice more options appear. For example, if you enable Versioning, a new Retention option appears (to prevent object deletion for a specified period). Also, if you enable Quota, you’ll then be required to define the quote in MB, GB, TB, BP, and EB. If you enable Retention, you will then have to configure it for either the Compliance or Governance mode as well as set a validity period (in days).
After making your configurations, click Create Bucket and MinIO will do its thing. After the bucket is created it will be empty. You can click Upload (Figure 3) to upload your first file to the object storage bucket.
-
Figure 3: A newly created MinIO storage bucket.
If you then click the gear icon in the upper right corner of the window, you’ll find yourself in the Bucket configuration window (Figure 4), where you can take care of options like access policies, encryption, quotas, replication,
Create Buckets from the CLI
Now, we’ll see how to do the same thing from the terminal window. Before we can do that, we must install the CLI client. Download the binary with:
1 |
sudo curl -o /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc |
Give the file the proper executable permissions with:
1 |
sudo chmod +x /usr/local/bin/mc |
Verify the installation with the command:
1 |
mc --version |
You should see something like this in the output:
mc version RELEASE.2022-11-07T23-47-39Z (commit-id=bc16bde337add744b25c47c4643491eba2a17c1b)
Runtime: go1.19.3 linux/amd64
Copyright (c) 2015-2022 MinIO, Inc.
License GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
We now need to add the MinIO server with the command:
1 |
mc alias set myminio http://SERVER:9000 admin PASSWORD |
Where SERVER is the domain or IP address of the hosting server and PASSWORD is the password you set for the admin user during the installation of MinIO.
You should see the following in the output:
1 |
Added `myminio` successfully |
You can view a list of current buckets with the command:
1 |
mc ls myminio |
You should see tnstest/ listed in the output.
Let’s create a new bucket with the command:
1 |
mc mb myminio/tns-bucket2 |
You should see the following in the output:
1 |
Bucket created successfully 'myminio/tns-bucket2'. |
Upload Files to the Bucket from the Command Line
Let’s create a test file and upload it to our new tns-bucket2 bucket. First, create the test file with:
1 |
touch test |
Next, upload the file to the tns-bucket2 with:
1 |
mc cp test myminio/test-bucket2 |
The file should upload immediately. To verify it’s in the bucket, list the contents with:
1 |
mc ls myminio/tns-bucket2 |
You should see the following in the output:
1 |
0B STANDARD test |
And that’s all there is to create a new object storage bucket with the MinIO web interface and the mc command line utility. With a bit of shell scripting magic, you could even automate the uploading of files to a bucket from the command line. Again, the sky’s the limit.