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.
2
Answers
You can try exposing port through docker port fowarding (network)
or
Please have a look at the guides:
https://docs.min.io/docs/setup-nginx-proxy-with-minio
You could use another address for signing (for example,
localhost:9000
to access it from your computer’s network). And then, you could apply proxy to the Minio client, so that it would make the actual request to the container in the docker network.I have managed it to work with the following code (example in dotnet):