I wanted to build a postgres docker container so my spring application can connect to it and use it. After booting up the container my application could not connect to it due to a fatal authentication error.
After unsuccessfully trying to connect to the db with dbeaver I can’t figure out where my problem is.
This is my docker compose file.
version: '2'
services:
db:
image: 'postgres:alpine'
container_name: productServicePostgres
ports:
- 0.0.0.0:5432:5432
environment:
POSTGRES_DB: "testDB"
POSTGRES_USER: "test"
POSTGRES_PASSWORD: "test"
I also tried to start a postgres container from command like this :
docker run --name postgres-0 -e POSTGRES_PASSWORD=test -d testdb -p 0.0.0.0:5432:5432 postgres:alpine
When I’m entering the container with docker exec -it productServicePostgres bash
and try to call psql
I’m getting the following error message.
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "root" does not exist