【发布时间】:2020-10-23 02:17:50
【问题描述】:
我使用 docker-compose 安装了 postgres 11。我想将它升级到 12,但即使我已经删除了容器及其卷,但容器的状态显示为“正在重新启动”。
这是我的 docker-compose 文件
version: '3.5'
services:
postgres:
image: postgres:12
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"
ports:
- "5432"
restart: always
volumes:
- /etc/postgresql/12/postgresql.conf:/var/lib/postgresql/data/postgresql.conf
- db_data:/var/lib/postgresql/data
volumes:
db_data:
但是它不工作并且日志有以下问题
2020-07-02T12:54:47.012973448Z The files belonging to this database system will be owned by user "postgres".
2020-07-02T12:54:47.013030445Z This user must also own the server process.
2020-07-02T12:54:47.013068962Z
2020-07-02T12:54:47.013222608Z The database cluster will be initialized with locale "en_US.utf8".
2020-07-02T12:54:47.013261425Z The default database encoding has accordingly been set to "UTF8".
2020-07-02T12:54:47.013281815Z The default text search configuration will be set to "english".
2020-07-02T12:54:47.013293326Z
2020-07-02T12:54:47.013303793Z Data page checksums are disabled.
2020-07-02T12:54:47.013313919Z
2020-07-02T12:54:47.013450079Z initdb: error: directory "/var/lib/postgresql/data" exists but is not empty
2020-07-02T12:54:47.013487706Z If you want to create a new database system, either remove or empty
2020-07-02T12:54:47.013501126Z the directory "/var/lib/postgresql/data" or run initdb
2020-07-02T12:54:47.013512379Z with an argument other than "/var/lib/postgresql/data".
当容器不断重启时,如何删除或清空这个 /var/lib/postgresql/data?
提前致谢
【问题讨论】:
-
从 Postgres 11 升级 --> 12 是一项重大升级,您不能只用一个替换另一个。如果 11 实例有与之关联的数据,您需要将 12 实例安装在另一个位置,然后执行转储/恢复或使用 pg_upgrade。
-
未来用户:请检查配置错误。对我来说,这是 yml 文件中的错字。
标签: postgresql docker docker-compose