From 02207d6b80711b5f4c363ba180d013d6ec81a95c Mon Sep 17 00:00:00 2001 From: Mohan K Date: Tue, 11 Aug 2026 13:01:34 +0530 Subject: [PATCH] Override pg_hba.conf using a custom file --- docker-compose.yaml | 12 +++--------- pg_hba.conf | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 pg_hba.conf diff --git a/docker-compose.yaml b/docker-compose.yaml index bdbed5b..de6549d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,20 +6,14 @@ services: POSTGRES_USER: admin POSTGRES_PASSWORD: password POSTGRES_DB: sop_monitoring - FORCE_RESTART: 3 + FORCE_RESTART: 4 ports: - "5432:5432" + command: ["postgres", "-c", "hba_file=/etc/postgresql/pg_hba.conf"] volumes: - ./db:/docker-entrypoint-initdb.d - pgdata:/var/lib/postgresql/data - - db_fixer: - image: alpine - restart: "no" - volumes: - - pgdata:/var/lib/postgresql/data - command: > - sh -c "find /var/lib/postgresql/data -name pg_hba.conf -exec sh -c 'echo \"local all all trust\" > \"$1\"; echo \"host all all 127.0.0.1/32 trust\" >> \"$1\"; echo \"host all all ::1/128 trust\" >> \"$1\"; echo \"host all all all md5\" >> \"$1\"; echo \"host all all all scram-sha-256\" >> \"$1\"' _ {} \;" + - ./pg_hba.conf:/etc/postgresql/pg_hba.conf api: diff --git a/pg_hba.conf b/pg_hba.conf new file mode 100644 index 0000000..4c89db1 --- /dev/null +++ b/pg_hba.conf @@ -0,0 +1,5 @@ +local all all trust +host all all 127.0.0.1/32 trust +host all all ::1/128 trust +host all all all md5 +host all all all scram-sha-256