DEV Community

Cover image for Deploying Minio using Docker Compose
Adnan Babakan (he/him)
Adnan Babakan (he/him)

Posted on

Deploying Minio using Docker Compose

Hey there DEV.to community!

As you might have heard about Minio, it is a free S3 storage server that you can set up and use locally or along your project to leverage the full potential of a powerful storage software and store your files inside with blazing fast response time.

Here is how to set it up using a Docker Compose file.

First of all, if you don't have it yet, create a file named docker-compose.yml.

Defining network

First of all we have to define a network so we can connect our server to it and share it between other services if we tend to do such a thing.

networks:
    minio-network:
        driver: bridge
Enter fullscreen mode Exit fullscreen mode

A bridge network allows your containers communicate with each other if they are on the same network while being isolated from other networks. And only publicly accessible if ports are published.

Defining volume

By defining a volume, we can keep our data persistent. Here is how to define one:

volumes:
  minio-volume:
    driver: local
Enter fullscreen mode Exit fullscreen mode

Defining service

Now it comes to Minio itself. By defining a service using the appropriate image from the docker registry we may start our service:

services:
  minio:
    image: minio/minio
    environment:
      - MINIO_ROOT_USER=root
      - MINIO_ROOT_PASSWORD=rootpass123
      - MINIO_DEFAULT_BUCKETS=bucket
    networks:
      - minio-network
    volumes:
      - minio-volume:/data
    ports:
      - "9222:9000"
      - "9223:9001"
    command: [ "server", "--console-address", ":9001", "/data" ]
Enter fullscreen mode Exit fullscreen mode

I've named my service minio which will create a container named after it. You may define another name for your service or define another container name using container_name attribute.

The minio/minio image is the official image to deploy minio so there won't be a change here.

Using environment variables we define the root username and password. Make sure your password is at elast 8 characters long as it is required by minio.

Attach the service to your created network using the networks attribute of the service.

Minio stores data at /data so map it to the volume we created before using volumes attribute.

Minio exposes two ports being 9000 for api and 9001 for web ui so expose them to public network using ports attribute.

And finally start the service using the command added above and DONE!

Final docker compose

Here is the final docker compose:

networks:
  minio-network:
    driver: bridge

volumes:
  minio-volume:
    driver: local


services:
  minio:
    image: minio/minio
    environment:
      - MINIO_ROOT_USER=root
      - MINIO_ROOT_PASSWORD=rootpass123
      - MINIO_DEFAULT_BUCKETS=bucket
    networks:
      - minio-network
    volumes:
      - minio-volume:/data
    ports:
      - "9222:9000"
      - "9223:9001"
    command: [ "server", "--console-address", ":9001", "/data" ]
Enter fullscreen mode Exit fullscreen mode

I hope this comes in handy and useful to you.


BTW! Check out my free Node.js Essentials E-book here:

Feel free to contact me if you have any questions, projects or suggestions to improve this article.

Top comments (0)