I am having trouble connecting to my database created from a Docker container. I'm getting this error Error: P1001: Can't reach database, and I assume it has something to do with the fact that the database is in the container while Prisma is on my machine.
My docker-compose file:
version: '3'
services:
db:
image: 'postgres:latest'
container_name: fynansus-db
env_file:
- .env
pgadmin:
image: 'dpage/pgadmin4'
container_name: fynansus-pgadmin
env_file:
- .env
ports:
- '8081:80'
depends_on:
- db
pdadmin works correctly and can connect with db.
and my .env
POSTGRES_PASSWORD=password
POSTGRES_USER=root
POSTGRES_DB=fynansus
DATABASE_URL="postgresql://root:password@db:5432/fynansus"
[email protected]
PGADMIN_DEFAULT_PASSWORD=123
I tried change the host of the url to ( localhost, db, fynansus-db, container-ip), but none of them work, i also tried to expose the port 5432 but dont work too.