Docker - PostgreSQL - FATAL - database files are incompatible with server

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2024
Перейти к:навигация, поиск

Доступная цена

Docker - PostgreSQL - FATAL - database files are incompatible with server

Ошибка при запуске контейнера docker с PostgreSQL 15:

PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-11-10 14:48:38.944 UTC [1] FATAL:  database files are incompatible with server
2023-11-10 14:48:38.944 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 11, which is not compatible with this version 15.4 (Debian 15.4-2.pgdg120+1).

Решение - это подчистить старый volume и создать его заново:

# docker volume ls
DRIVER    VOLUME NAME
local     pgdata
# docker rm cb5ff92c3ef8 -f
# docker volume rm pgdata -f
# docker volume create pgdata

и повторить создание контейнера:

# docker create --name=db -e POSTGRES_DB=wiki1 -e POSTGRES_USER=wiki1 -e POSTGRES_PASSWORD_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -v pgdata:/var/lib/postgresql/data --restart=unless-stopped -h db --network=wikinet postgres:15
# docker start cc29e91770e1


PostgreSQL init process complete; ready for start up.
2023-11-10 14:54:55.140 UTC [1] LOG:  starting PostgreSQL 15.4 (Debian 15.4-2.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2023-11-10 14:54:55.151 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-11-10 14:54:55.151 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-11-10 14:54:55.201 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-11-10 14:54:55.262 UTC [64] LOG:  database system was shut down at 2023-11-10 14:54:54 UTC
2023-11-10 14:54:55.296 UTC [1] LOG:  database system is ready to accept connections