Postgresコンテナ構築時にユーザーパスワードを変更する際のエラー

コンテナにPostgresが正常にインストールされた後、ランチャースクリプトはdiscourseユーザーのパスワードを変更しようとしますが、このエラーが発生します。

Pups::ExecError: su - postgres -c 'psql discourse' failed with return #<Process::Status: pid 100 exit 141>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"stdin"=>"alter user discourse with password 'redacted';\n", "cmd"=>"su - postgres -c 'psql discourse'", "raise_on_fail"=>true}
bootstrap failed with exit code 141
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

このコマンドに到達したときにPostgresが実行されていないため、broken pipeで失敗しているようです。私のpostgres.ymlはdata.ymlのサンプルファイルに基づいているのですが、何が間違っているのかわかりません。何かアイデアはありますか?

そして、それらをここに共有していただけますか?

「いいね!」 1

こんにちは。以前のログには特に目立ったものはありませんでしたが、コンテナログにこのメッセージが表示されていることに気づきました。

2024-01-26 12:30:54 I, [2024-01-26T17:30:54.465403 #1]  INFO -- : Reading from stdin
2024-01-26 12:30:54 /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/config.rb:22:in `block in initialize': undefined method `has_key?' for nil:NilClass (NoMethodError)
2024-01-26 12:30:54
2024-01-26 12:30:54         @config[key] = {} unless @config.has_key?(key)
2024-01-26 12:30:54                                         ^^^^^^^^^
2024-01-26 12:30:54     from /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/config.rb:21:in `each'
2024-01-26 12:30:54     from /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/config.rb:21:in `initialize'
2024-01-26 12:30:54     from /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/cli.rb:68:in `new'
2024-01-26 12:30:54     from /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/cli.rb:68:in `run'
2024-01-26 12:30:54     from /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/bin/pups:9:in `<top (required)>'
2024-01-26 12:30:54     from /usr/local/bin/pups:25:in `load'
2024-01-26 12:30:54     from /usr/local/bin/pups:25:in `<main>'

これは、after_postgres のパスワード変更をコメントアウトしても、コンテナがクラッシュします。これが broken pipe の原因です。