accessing the minio object presigned get URL both from inside and outside docker container

Viewed 1133

I used the following docker-compose.yml file to deploy a FastAPI, MongoDB, Minio docker containers.

version: '3.7'
services: 
  db:
    image: mongo:latest
    container_name: mongodb
    user: 1000:1000
    volumes: 
      - /home/krishna/mongodb/db:/data/db

  minio:
    image: minio/minio:latest
    container_name: minio
    command: server /data --console-address ":9001"
    ports:
      - 9000:9000
      - 9001:9001
    volumes:
      - /data:/data

  app:
    build: .
    container_name: imaging_container
    ports:
      - 8888:8888

From inside the FastAPI, I am able to connect to the minio instance using minio:9000 endpoint. API returns the output of get_presigned_url for a requested minio object but the url is in the form of http://minio:9000/imaging/images/30d12c89... which I am not able to access from outside the docker container.

I found a quickfix/workaround to resolve this i.e. adding this line to /etc/hosts file works

127.0.0.1       minio

But this looks to me a cheap solution where host has to modify his/her machine.

I feel like this can be resolved easily by adding nginx proxy to the docker container. But I am not sure how to go about doing that?

It would be helpful if you can suggest the nginx configuration setup to resolve this, or alternatively any other suggestions are also welcome.

1 Answers
Related