1

I have to create a spatial PostgreSQL database with Docker ans I have the following problem :

System : macOS Catalina, version 10.15.7 docker v.20.10 Python v.3.7.7
postgreSQL v.13.1 install with Brew

I enter this in my terminal to create a PostgreSQL server listening on the 5432 port with docker.

 docker run --name=postgis -d -e POSTGRES_PASS=123456789 -p 5432:5432 kartoza/postgis:9.6-2.4`

Then:

`docker exec -it postgis bash`

it contained the following elements : https://i.stack.imgur.com/2VabD.png

Then I tried to access the database :

psql -U postgres

I've got this message : psql: FATAL: Peer authentication failed for user "postgres"

When I inspect the logs in docker I see this :

 postgres@postgres DETAIL: Connection matched pg_hba.conf line 85: "local all postgres peer"

I open the pg_hba.conf with Sublime Text in usr/local/var/postgres/pg_hba_conf

But all methods were TRUST and line 85 was different. I still modified by putting md5 everywhere. Then I did the following command:

brew services restart postgresql

I repeated but always the same error message and the same sentence when inspecting the logs.

It seems that my postgreSQL uses another file than the pg_hba.conf I see, yet I can't find anything else.

thanks in advance

  • I believe the issue is similar to https://stackoverflow.com/questions/60193781/postgres-with-docker-compose-gives-fatal-role-root-does-not-exist-error/60194261#60194261, except you're encountering this with `postgres` user instead of `root` user – richyen Jan 07 '21 at 03:18
  • I have the same issue with the `kartoza/postgis` docker image...did you find the solution? – Big_Boulard Aug 29 '23 at 13:21

1 Answers1

0

Try using psql -U postgres -W to make PostgreSQL ask you for password.

S.B
  • 13,077
  • 10
  • 22
  • 49