0

I am able to use docker-compose -f postgres.yaml build to build the below file and bring it up, I can login successfully via

docker exec -it <image> psql -h localhost -U postgres

and then enter the password. However, I need to be able to login via command line of localhost.

Like psql -h localhost -U postgres, then enter password. When I attempt this I get:

FATAL: password authentication failed for user 'postgres'. Password does not match for user "postgres". If I hardcode the password inside the compose file I am able to login via localhost command line.

My Docker compose file:

version: '3.1'

services:
  db:
    image: postgres:latest
    build:
      context: .
      dockerfile: Dockerfile.postgres
    restart: always
    secrets:
      - postgres_db_password
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD_FILE: ./run/secrets/postgres_db_password
    ports:
      - 5432:5432

secrets:
  postgre_db_password:
    file: .postgres_db_password.txt

Docker.postgres file: FROM postgis/postgis:10-3.0-alpine

1 Answer 1

1

You should check if there is no trailing character in your secret (like end of line) as mentionned in this post.

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

2 Comments

This was it!!! Jeez, I have spent hours on this!! Thanks!!
Great ! You can validate my answer :)

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.