排错-harbor-db容器异常重启
排错-harbor-db容器异常重启
环境:
docker 19.03 , harbor-db(postgresql) goharbor/harbor-db:v2.5.6
现象:
harbor-db 容器一直restart,查看日志发现 报错
initdb: error: directory "/var/lib/postgresql/data/pg13" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/postgresql/data/pg13" or run initdb
with an argument other than "/var/lib/postgresql/data/pg13".
ls: cannot access '/var/lib/postgresql/data': Operation not permitted
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
(默认的docker-compose log driver走了tcp syslog, 可以自行更改)
原因:
看报错提示是由于数据目录不为空导致初始化失败,docker-compose.yml 中将宿主机目录 /data/database 挂载进容器的
解决:
解决办法一:
不保留数据,清空容器宿主机上的数据目录 ,再重启重启就行
#rm -rf /data/database/*
解决办法二:
保留数据,docker-compose.yml中新增 privileged: true ,使用特权模式, ,再重启重启就行