I am trying to have a nestjs app with a psql database dockerized. I have a docker-compose.yml:
# docker-compose.yml
version: '3.8'
services:
postgres:
image: postgres:13
container_name: postgres_albert
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- postgres:/var/lib/postgresql/data
ports:
- '5432:5432'
volumes:
postgres:
name: volume-uni
Then I access the container:
docker exec -it 36cf6358a019 bash
And try to use psql:
psql -U postgres
I get following error:
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "postgres" does not exist
I don't understand, postgres is the official user and is there when installation. I used the official image without docker-compose with the postgres user and it worked. I tried also changing users but no success