排錯-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 ,使用特權模式, ,再重啟重啟就行