1. 数据卷挂载配置
2. 错误日志
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
initdb: error: directory "/var/lib/postgresql/data" exists but is not empty
It contains a lost+found directory, perhaps due to it being a mount point.
Using a mount point directly as the data directory is not recommended.
Create a subdirectory under the mount point.
3. 错误分析
根据错误日志提示,挂载卷下存在一个 lost+found
目录,并且不推荐直接使用挂载点作为数据目录。
需要在挂载点下创建一个子目录来解决问题。
4. 正确配置
只需要在子路径按需求取个目录名称即可,我这里就使用 data
,问题解决。