Setting Up MinIO for S3-Compatible Local File Storage
Run a local MinIO object store, create a bucket, connect with the AWS SDK, and understand production deployment safeguards.
TechSilo
Technology writer & developer
MinIO is an S3-compatible object-storage server. It is useful for local development, testing file-upload flows, and environments where you operate your own object storage. Production deployment requires careful attention to persistence, credentials, networking, backups, and supported distribution options.
Prerequisites
Install Docker and Docker Compose, and make sure ports 9000 (API) and 9001 (console) are available locally. Treat the credentials in this example as placeholders for a private test machine.
Step 1: Start a development server
Create a compose.yaml file:
services:
minio:
image: quay.io/minio/minio:latest
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: localadmin
MINIO_ROOT_PASSWORD: change-this-dev-password
ports:
- "127.0.0.1:9000:9000"
- "127.0.0.1:9001:9001"
volumes:
- minio-data:/data
volumes:
minio-data:Run:
docker compose up -d
docker compose logs -f minioOpen http://localhost:9001 and log in using the development credentials. Create a bucket called uploads using the console.
Production warning: Do not use the mutable latest tag or hard-coded root credentials for a real service. Pin an appropriate tested release, use a secret manager, enable TLS, and restrict administrative access.
Step 2: Connect from Node.js
Install an S3-compatible client:
npm install @aws-sdk/client-s3import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
const s3 = new S3Client({
region: 'us-east-1',
endpoint: 'http://127.0.0.1:9000',
forcePathStyle: true,
credentials: {
accessKeyId: process.env.MINIO_ACCESS_KEY,
secretAccessKey: process.env.MINIO_SECRET_KEY,
},
});
await s3.send(new PutObjectCommand({
Bucket: 'uploads',
Key: 'hello.txt',
Body: 'Hello from TechSilo',
ContentType: 'text/plain',
}));Set the local environment variables to valid credentials before running the script. For real applications, create a scoped application identity instead of reusing the root credentials.
Step 3: Verify the upload
Open the MinIO console and inspect the uploads bucket. You should see hello.txt with the expected contents. If the operation fails, inspect the container logs and verify the bucket exists.
Troubleshooting
Connection refused: Check docker compose ps, port mappings, and the hostname used by the client. A different Docker container generally cannot reach a peer through 127.0.0.1; use the service DNS name on a shared Compose network.
Signature mismatch: Confirm that the access key and secret correspond to the intended server, and that your endpoint, region, and signing settings are compatible.
Access denied: Verify the principal's bucket policy and permissions. Don't grant global administrative access to fix an application-policy error.
Production checklist
Use encrypted transport, rotate credentials, restrict exposure with firewalls or a proxy, monitor disk capacity, and plan backups and recovery tests. A Docker volume does not replace a backup. Multipart uploads, presigned URLs, and lifecycle rules may help with larger applications, but test these against your selected MinIO version.
For handling file inputs securely, read [Troubleshooting File Upload Size Limits](/blog/troubleshooting-file-upload-size-limits-mr1jse6s).
Want to put this into practice?
Explore TechSilo's free developer tools for practical utilities you can use directly in your browser.
Try these free tools
JSON Formatter
The fastest free JSON formatter and validator for developers. Pretty-print API responses, fix broken JSON syntax, and validate JSON without uploading your data.
Open toolRegex Tester
Validate regular expressions instantly, highlight matches, and debug regex groups in real time.
Open toolAI Code Explainer
Paste any code snippet and get a plain-English breakdown with bug warnings, logic explanation, and improvement suggestions.
Open toolRelated blog posts
Setting Up Docker for Local Development
To set up Docker for local development, you'll need a computer with a 64-bit operating system (Windows 10 or macOS 10.13 or later), at least 4 GB of RAM, and a compatible processor. You'll…
Read postSetting Up a GitHub Actions CI/CD Pipeline
To set up a GitHub Actions CI/CD pipeline, you'll need a GitHub account, a repository with your project code, and Node.js (version 14 or higher) installed on your machine. You'll also need…
Read postSetting up Tailwind CSS with a Custom Theme
To set up Tailwind CSS with a custom theme, you'll need Node.js (version 16.14.2 or higher) and npm (version 8.5.5 or higher). You'll also need a code editor and a terminal.
Read postSetting up Tailwind CSS with a Custom Theme
To set up Tailwind CSS with a custom theme, you'll need Node.js (version 16.14.2 or higher) and npm (version 8.5.5 or higher) installed on your machine. You'll also need a code editor and a…
Read postSetting Up a Prometheus Monitoring Stack
To set up a Prometheus monitoring stack, you'll need Docker (version 20.10 or later) and docker-compose (version 1.29 or later) installed on your system. You'll also need a basic…
Read post