Remotec
Remotec

Reputation: 10770

Authentication error when connecting to Postgres in a Docker container

I'm getting the following error when I try to connect to a Postgres database inside a Docker container. I'm using pgAdmin 4 on windows as my client.

Password does not match for user "postgres".

My docker-compose file is as follows:

version: "3"
services:
  db:
    image: postgres
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
    ports:
      - "5433:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes: 
  pgdata:

Not sure what I'm doing wrong. The file states that the username and password are both postgres. I was able to connect when I just docker run the image. Now I'm using the compose file I seem to be getting this problem.

Upvotes: 2

Views: 963

Answers (1)

Remotec
Remotec

Reputation: 10770

Fixed by doing the following:

  • Stopped container.
  • Removed container.
  • Removed volume.

Volume must have contained previous configuration.

Upvotes: 4

Related Questions