diff --git a/postgres-12-image/docker-entrypoint.sh b/postgres-12-image/docker-entrypoint.sh index 0ae0ecf8c..5d411ca11 100644 --- a/postgres-12-image/docker-entrypoint.sh +++ b/postgres-12-image/docker-entrypoint.sh @@ -88,8 +88,10 @@ docker_init_database_dir() { set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@" fi + [ -z "$POSTGRES_HOST_AUTH_METHOD" ] || AUTH_ARGS="--auth=${POSTGRES_HOST_AUTH_METHOD}" + # --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025 - eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"' + eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") $AUTH_ARGS '"$POSTGRES_INITDB_ARGS"' "$@"' # unset/cleanup "nss_wrapper" bits if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then diff --git a/postgres-13-image/docker-entrypoint.sh b/postgres-13-image/docker-entrypoint.sh index 0ae0ecf8c..5d411ca11 100644 --- a/postgres-13-image/docker-entrypoint.sh +++ b/postgres-13-image/docker-entrypoint.sh @@ -88,8 +88,10 @@ docker_init_database_dir() { set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@" fi + [ -z "$POSTGRES_HOST_AUTH_METHOD" ] || AUTH_ARGS="--auth=${POSTGRES_HOST_AUTH_METHOD}" + # --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025 - eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"' + eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") $AUTH_ARGS '"$POSTGRES_INITDB_ARGS"' "$@"' # unset/cleanup "nss_wrapper" bits if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then diff --git a/postgres-14-image/docker-entrypoint.sh b/postgres-14-image/docker-entrypoint.sh index 0ae0ecf8c..5d411ca11 100644 --- a/postgres-14-image/docker-entrypoint.sh +++ b/postgres-14-image/docker-entrypoint.sh @@ -88,8 +88,10 @@ docker_init_database_dir() { set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@" fi + [ -z "$POSTGRES_HOST_AUTH_METHOD" ] || AUTH_ARGS="--auth=${POSTGRES_HOST_AUTH_METHOD}" + # --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025 - eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"' + eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") $AUTH_ARGS '"$POSTGRES_INITDB_ARGS"' "$@"' # unset/cleanup "nss_wrapper" bits if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then diff --git a/postgres-15-image/docker-entrypoint.sh b/postgres-15-image/docker-entrypoint.sh index 0ae0ecf8c..5d411ca11 100644 --- a/postgres-15-image/docker-entrypoint.sh +++ b/postgres-15-image/docker-entrypoint.sh @@ -88,8 +88,10 @@ docker_init_database_dir() { set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@" fi + [ -z "$POSTGRES_HOST_AUTH_METHOD" ] || AUTH_ARGS="--auth=${POSTGRES_HOST_AUTH_METHOD}" + # --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025 - eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"' + eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") $AUTH_ARGS '"$POSTGRES_INITDB_ARGS"' "$@"' # unset/cleanup "nss_wrapper" bits if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then