skip to Main Content

I have Minio in docker container called "be_minio". I want connect to that container with my app from another container called "be_api".

be_api:
    build: .
    restart: always
    ports:
      - 8080:80
    depends_on:
      - be_minio

be_minio:
    image: minio/minio
    restart: always
    ports:
      - 9000:9000
      - 9001:9001
    volumes:
      - ./volume_minio:/data
    command: server --address ":9000" --console-address ":9001" /data
    environment:
      ...

Config file with node sdk

const Minio = require('minio')

const minioClient = new Minio.Client({
    endPoint: "be_minio",
    port: 9000,
    useSSL: false,
    accessKey: ...,
    secretKey: ...
})

export default minioClient

But endPoint "be_minio" is not valid url.

S3Error: Invalid Request (invalid hostname)

Is there some solution for that ? E.g some networking, or something like that ?

2

Answers


  1. Chosen as BEST ANSWER

    After long time of searching, trying, coding, etc, I found some mistakes, but what exactly caused the problem isn't clear.

    1. Use dash in docker-compose service names instead of underscore
    2. Envs are just strings Boolean(process.env.ssl) ## Boolean("false") -> true

    Although I managed to get this working, when I generate public url, minioClient return docker-compose service name as domain :(.


  2. Although I managed to get this working, when I generate public url, minioClient return docker-compose service name as domain :(.

    You should be using X-Forwarded HTTP headers. Check this doc with Nginx as example: https://min.io/docs/minio/linux/integrations/setup-nginx-proxy-with-minio.html

       location /minio {
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
          ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search