Search code examples
spring-bootdockerminio

Cannot open Minio in browser after dockerizing it in Spring Boot App


I have a problem in opening minio in the browser. I just created Spring Boot app with the usage of it.

Here is my application.yaml file shown below.

server:
  port: 8085
spring:
  application:
    name: springboot-minio
minio:
  endpoint: http://127.0.0.1:9000
  port: 9000
  accessKey:  minioadmin #Login Account
  secretKey:  minioadmin # Login Password
  secure: false
  bucket-name: commons # Bucket Name
  image-size: 10485760 #  Maximum size of picture file
  file-size: 1073741824 #  Maximum file size

Here is my docker-compose.yaml file shown below.

version: '3.8'

services:
  minio:
    image: minio/minio:latest
    container_name: minio
    environment:
      MINIO_ROOT_USER: "minioadmin"
      MINIO_ROOT_PASSWORD: "minioadmin"
    volumes:
      - ./data:/data
    ports:
      - 9000:9000
      - 9001:9001

I run it by these commands shown below.

1 ) docker-compose up -d
2 ) docker ps -a
3 ) docker run minio/minio:latest

Here is the result shown below.

C:\Users\host\IdeaProjects\SpringBootMinio>docker run minio/minio:latest
NAME:
  minio - High Performance Object Storage

DESCRIPTION:
  Build high performance data infrastructure for machine learning, analytics and application data workloads with MinIO

USAGE:
  minio [FLAGS] COMMAND [ARGS...]

COMMANDS:
  server   start object storage server
  gateway  start object storage gateway

FLAGS:
  --certs-dir value, -S value  path to certs directory (default: "/root/.minio/certs")
  --quiet                      disable startup information
  --anonymous                  hide sensitive information from logging
  --json                       output server logs and startup information in json format
  --help, -h                   show help
  --version, -v                print the version

VERSION:
  RELEASE.2022-01-08T03-11-54Z

When I write 127.0.0.1:9000 in the browser, I couldn't open the MinIo login page.

How can I fix my issue?


Solution

  • The MinIO documentation includes a MinIO Docker Quickstart Guide that has some recipes for starting the container. The important thing here is that you cannot just docker run minio/minio; it needs a command to run, probably server. This also needs to be translated into your Compose setup.

    The first example on that page breaks down like so:

    docker run                     \
      -p 9000:9000 -p 9001:9001    \  # publish ports
      -e "MINIO_ROOT_USER=..."     \  # set environment variables
      -e "MINIO_ROOT_PASSWORD=..." \
      quay.io/minio/minio          \  # image name
      server /data --console-address ":9001"  # command to run
    

    That final command is important. In your example where you just docker run the image and get a help message, it's because you omitted the command. In the Compose setup you also don't have a command: line; if you look at docker-compose ps I expect you'll see the container is exited, and docker-compose logs minio will probably show the same help message.

    You can include that command in your Compose setup with command::

    version: '3.8'
    services:
      minio:
        image: minio/minio:latest
        environment:
          MINIO_ROOT_USER: "..."
          MINIO_ROOT_PASSWORD: "..."
        volumes:
          - ./data:/data
        ports:
          - 9000:9000
          - 9001:9001
        command: server /data --console-address :9001  # <-- add this