Skip to content
Back to all posts
Technology

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.

3 min read

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:

yaml
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:

bash
docker compose up -d
docker compose logs -f minio

Open 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:

bash
npm install @aws-sdk/client-s3
javascript
import { 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

Related blog posts