Docker Community Forums

Share and learn in the Docker community.

Unanle to connect to Database created with docker-compose up

Hello everyone!!! I am a newbie in docker. However, I have been having the challenge of connecting my postgres database I created with docker to prisma. But keep getting this error

Error: P1000: Authentication failed against database server at localhost, the provided database credentials for postgres are not valid.

Please make sure to provide valid database credentials for the database server at localhost.

This is my docker-compose.yml file
version: ‘3’

services:

pg:

    image: postgres:13

    restart: 'always'

    expose:

        - '5432'

    ports:

        - '5432:5432'

    environment:

        - POSTGRES_DB=prisma

        - POSTGRES_HOST_AUTH_METHOD=trust

    volumes:

        - './db/data:/var/lib/postgres/data'

        - './db/init:/docker-entrypoint-initdb.d'

and my .env file
DATABASE_URL=“postgresql://postgres:@localhost:5432/prisma”

What have i done wrong? Please I need help asap
Thanks

What happens when you use:

DATABASE_URL=“postgresql://postgres:postgres@localhost:5432/prisma”

.env file?