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 Answers1

1

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

Cyril G.
  • 1,879
  • 2
  • 5
  • 19