2

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.

1 Answer 1

4

Fixed by doing the following:

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

Volume must have contained previous configuration.

Sign up to request clarification or add additional context in comments.

2 Comments

For me it didn't work even if you are right. Looks like old password has been stored somewhere deeper. So I had to change password back... And then connect to the running container and change it through alter user
The key seemed to be removing the container and volume to completely clear it up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.