postgre容器一直处于restarting状态,无法启动的问题

问题原因:

修改了postgre容器的配置(postgresql.conf) ,stop容器再重启后,发现容器一直postgre容器一直处于restarting状态

问题排查:

1. 通过指令:docker logs 容器名称 ;查看容器启动日志,发现最后一直打印:

2023-06-20 07:20:54.213 UTC [1] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-06-20 07:20:54.213 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-06-20 07:20:54.213 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-06-20 07:20:54.220 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-06-20 07:20:54.229 UTC [1] LOG:  invalid connection type "*host"
2023-06-20 07:20:54.229 UTC [1] CONTEXT:  line 92 of configuration file "/var/lib/postgresql/data/pg_hba.conf"
2023-06-20 07:20:54.229 UTC [1] FATAL:  could not load pg_hba.conf
2023-06-20 07:20:54.231 UTC [1] LOG:  database system is shut down

2. 通过指令: docker inspect 容器名称;查看容器基本详情信息。

3. 在基本详情信息里面找到宿主机挂载配置路径:

 .... 
"Mounts":[
 ....
            {
           "Source":"/var/lib/docker/volumes/e7fa35b390e1e19486c0c6f38439506ab6a62f21fb87117135adf04209e32391/_data",
 
            }
        ],
 ....

4. 直接在宿主机上/本地上进入上面的文件夹:

cd /var/lib/docker/volumes/e7fa35b390e1e19486c0c6f38439506ab6a62f21fb87117135adf04209e32391

5. 在这个文件夹里面找到上面日志的pg_hba.conf文件,根据日志显示是92行有问题,那直接编辑该文件的第92行,把该行直接注销掉,然后wq保存退出

6. 保存退出文件后,容器即正常启动

你可能感兴趣的:(postgresql,docker)