I have a service that runs inside a docker container. This service need to accesses the database that is run in another cluster (I use kubectl port-forward and after it I access database in localhost:5432)
Here is my docker-compose file
version: '3'
services:
api:
build: .
ports:
- "8000:8000"
- "5432:5432"
environment:
- APP_PORT=8000
- DB_SERVER=localhost
- DB_PORT=5432
- DB_USER=postgres
- DB_PASSWORD=mypassword
It seems that redirection of port 5432 does not work as expected because connection to database fails inside the container. Could you help me to understand what's going wrong?