まらんさんのチラ裏

その日暮らしのおじさん

Docker PostgreSQL で could not open file "pg_wal/000000010000000000000001": No such file or directory

docker で postgresql を起動させるとエラーがでて死んでしまうことがあって、これは困ったなあということで色々調べたんですけど全然それっぽい解決策がなかったんですよね。
で、仕方ないからあれこれと試して回ってみたら Docker Desktop の割と新し目の機能である VirtioFS が悪さしているっぽいことが判明。
Experimental Feature としてリリースされるずっと前からこの機能を楽しみにしていて、「やっときたぜ!」と意気揚々として有効化していたんですけどこいつがすべての元凶だったようなので仕方なく無効化しまし た。
Experimental なんだからしょうがないよね。しょぼん。

こんなログでコケてました。

postgres-1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres-1  | creating subdirectories ... ok
postgres-1  | selecting dynamic shared memory implementation ... posix
postgres-1  | selecting default max_connections ... 100
postgres-1  | selecting default shared_buffers ... 128MB
postgres-1  | selecting default time zone ... Etc/UTC
postgres-1  | creating configuration files ... ok
postgres-1  | 2022-05-12 09:29:52.039 UTC [41] LOG:  could not open file "pg_wal/000000010000000000000001": No such file or directory
postgres-1  | 2022-05-12 09:29:52.039 UTC [41] FATAL:  could not open file "pg_wal/000000010000000000000001": No such file or directory
postgres-1  | child process exited with exit code 1
postgres-1  | initdb: removing contents of data directory "/var/lib/postgresql/data"
postgres-1  | running bootstrap script ... The files belonging to this database system will be owned by user "postgres".
postgres-1  | This user must also own the server process.

無効化して解決。

新しめの機能だし、同じように困ってる人もいるんじゃないかと思うので参考になれば幸いです。