🕌

docker-composeでpostgresqlが起動時に「PostgreSQL Database directory ...」

2021/12/05に公開

概要

realworld の laravel バージョン laravel-realword-example-app を一度起動した後に再起動しようとしたときに、以下のようなエラーが発生しました。

解決策についてメモします。

https://github.com/f1amy/laravel-realworld-example-app

pgsql_1         |
pgsql_1         | PostgreSQL Database directory appears to contain a database; Skipping initialization
pgsql_1         |
pgsql_1         | 2021-10-09 22:42:10.252 UTC [1] FATAL:  database files are incompatible with server
pgsql_1         | 2021-10-09 22:42:10.252 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0.

エラー全文

Creating laravel-realworld-example-app_pgsql_1 ... done
Creating laravel-realworld-example-app_laravel.test_1 ... done
Attaching to laravel-realworld-example-app_pgsql_1, laravel-realworld-example-app_laravel.test_1
pgsql_1         |
pgsql_1         | PostgreSQL Database directory appears to contain a database; Skipping initialization
pgsql_1         |
pgsql_1         | 2021-10-09 22:42:10.252 UTC [1] FATAL:  database files are incompatible with server
pgsql_1         | 2021-10-09 22:42:10.252 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0.
laravel-realworld-example-app_pgsql_1 exited with code 1
laravel.test_1  | 2021-10-09 22:42:13,292 INFO Set uid to user 0 succeeded
laravel.test_1  | 2021-10-09 22:42:13,295 INFO supervisord started with pid 16
laravel.test_1  | 2021-10-09 22:42:14,300 INFO spawned: 'php' with pid 17
laravel.test_1  | 2021-10-09 22:42:15,305 INFO success: php entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
laravel.test_1  | Starting Laravel development server: http://0.0.0.0:80
laravel.test_1  | [Sat Oct  9 22:42:17 2021] PHP 8.0.11 Development Server (http://0.0.0.0:80) started

解決方法

docker volumeを削除する必要があるみたいでした。

> docker volume rm $(docker volume ls -qf dangling=true)
laravel-realworld-database

Discussion