I'm writing a docker-compose file to launch some services. But the db service is a trouble maker, I always get this error:
FATAL:  password authentication failed for user "postgres"
DETAIL:  Password does not match for user "postgres".
Connection matched pg_hba.conf line 95: "host all all all md5"
I've read a lot of threads, and I've correctly set the POSTGRES_USER and POSTGRES_PASSWORD. I have also remove the previous volumes and container to force postgresql to re-init the password. But I can't figure out why it's still not working.
So what is the correct way to force the re-initialization of the postgresql image. So I would be able to connect to my database.
I've seen that this error: Connection matched pg_hba.conf line 95: "host all all all md5", and I've heard about the postgres conf file. But it's an official container it's supposed to work, isn't it ?
version: '3'
services:
  poll:
    build: poll
    container_name: "poll"
    ports:
      - "5000:80"
    networks:
      - poll-tier
    environment:
      - REDIS_HOST=redis
    depends_on:
      - redis
  worker:
    build: worker
    container_name: "worker"
    networks:
      - back-tier
    environment:
      - REDIS_HOST=redis
      - POSTGRES_HOST=db
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root
    depends_on:
      - redis
      - db
  redis:
    image: "redis:alpine"
    container_name: "redis"
    networks:
      - poll-tier
      - back-tier
  result:
    build: result
    container_name: "result"
    ports:
      - "5001:80"
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root
      - POSTGRES_HOST=db
      - RESULT_PORT=80
    networks:
      - result-tier
    depends_on:
      - db
  db:
    image: "postgres:alpine"
    container_name: "db"
    restart: always
    networks:
      - back-tier
      - result-tier
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root
      - POSTGRES_DB=postgres
volumes:
  db-data:
    driver: local
networks:
  poll-tier: {}
  back-tier: {}
  result-tier: {}
I'm expected to get the db connected, and not password authentication failed for user "postgres".





bash-ing into one of the non-dbcontainers, install postgres, and then try topsql -h db -c "select 1" postgres postgres? I'm curious to know if the application is storing the wrong password