Skip to content

FATAL: password authentication / DETAIL: Role “” does not exist. #773

@ebolasudan

Description

@ebolasudan

I have been looking for a workaround for 3 days now and it seems to be a fairly common issue that I can't seem to fix for myself due to my lack of knowledge with docker/Postgres. I believe it has something to do with the volume not being able to write.

the errors I've been able to see are ;

FATAL: password authentication failed for user "app"
DETAIL: Role “app” does not exist. Connection matched pg_hba.conf line 95: “host all all all md5”

So I can see that the user is not being created for some reason. nor is the DB and at this point, I don't even know how to change this pg_hba.conf file nor why it should be needed to be changed in the first place on an official docker image. I would assume that it would work right off the bat. I am constantly deleting the images and rebuilding them trying to make changes with no hope so far.

What am I missing and how can I fix this so I can actually do something with Postgres?

version: "3"

services:
  api:
    ports:
      - 8000:8000
    build:
      context: ./app
      dockerfile: ./Dockerfile
      args:
        STATIC_URL: "/static/"
    restart: unless-stopped
    networks:
      - app-backend-tier
    depends_on:
      - db
    volumes:
      - ./app/app/:/app:Z
      - ./app/templates/:/app/templates:Z
      - ./app/tests/:/app/tests
      # shared volume between worker and api for media
      - app-media:/app/media
    command: >
      sh -c "python manage.py makemigrations &&
             python manage.py migrate_schemas --shared &&
             python manage.py runserver 0.0.0.0:8000"
    #  python manage.py createtenant"
    env_file: common.env
    environment:
      - DB_HOST=db
      - DB_NAME=app
      - DB_USER=app
      - DB_PASS=app
      - DB_PORT=5432
      - Application_URL=http://localhost:9000/
      - DASHBOARD_URL=http://localhost:3000/

  db:
    container_name: db
    image: postgres:13
    ports:
      - "5432:5432"
    restart: unless-stopped
    networks:
      - app-backend-tier
    volumes:
      - app-db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=app
      - POSTGRES_USER=app
      - POSTGRES_PASSWORD=app

  pgadmin:
    image: dpage/pgadmin4
    environment:
      - PGADMIN_DEFAULT_EMAIL=test@email.non
      - PGADMIN_DEFAULT_PASSWORD=app
    ports:
      - "8889:80"
    networks:
      - app-backend-tier
volumes:
  app-db:
    driver: local

networks:
  app-backend-tier:
    driver: bridge

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions