kartoza / docker-postgis

Dockerfile for postgis
GNU General Public License v2.0
660 stars 313 forks source link

postgres@postgres FATAL: Peer authentication failed for user "postgres" #446

Closed cecililu closed 1 year ago

cecililu commented 1 year ago

What is the bug or the crash?

real-db-1 | 2023-09-06 13:41:44.745 UTC [299] postgres@postgres LOG: provided user name (postgres) and authenticated user name (root) do not match real-db-1 | 2023-09-06 13:41:44.745 UTC [299] postgres@postgres FATAL: Peer authentication failed for user "postgres" real-db-1 | 2023-09-06 13:41:44.745 UTC [299] postgres@postgres DETAIL: Connection matched pg_hba.conf line 90: "local all postgres peer"

Steps to reproduce the issue

db:
    image: kartoza/postgis:15-3.4
    restart: always
    volumes:
      - ./postgres_data:/var/lib/postgresql/data/
    ports:
      - 5432:5432
    env_file:
      - .db_env
    networks:
      - test_nw
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

where .db_env

POSTGRES_USER=postgres
POSTGRES_DB=ag_db
POSTGRES_PASS=postgres
PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org
PGADMIN_DEFAULT_PASSWORD=root
ALLOW_IP_RANGE=0.0.0.0/0
RUN_AS_ROOT=false
POSTGRES_UID=1000
POSTGRES_GID=1000
USER=postgresuser
GROUP_NAME=postgresusers
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=root

Versions

kartoza/postgis:15-3.4

Additional context

Seems to show that error even though works fine. Also can i not use bind mount instead of volume mount?When i compose down and up data seems to be gone.Does making bind mount not persist data as above

NyakudyaA commented 1 year ago

Generally it's not recommended to set a user as postgres, there is already a super user account for that. We might even prevent this specific username in future.

Try using foo or something different