Postgres shuts down immediately when started with docker-compose

纵然是瞬间 提交于 2019-12-03 10:11:00

I tried your docker-compose and the service seems running in the container:

root@0afe99de0f0b:/# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
postgres     1  0.5  0.8 227148 16128 ?        Ss   14:42   0:00 postgres
postgres    74  0.0  0.0 227148  1768 ?        Ss   14:42   0:00 postgres: checkpointer process  
postgres    75  0.0  0.0 227148  1772 ?        Ss   14:42   0:00 postgres: writer process  
postgres    76  0.0  0.0 227148  1768 ?        Ss   14:42   0:00 postgres: wal writer process  
postgres    77  0.0  0.1 227576  2720 ?        Ss   14:42   0:00 postgres: autovacuum launcher process  
postgres    78  0.0  0.0  82132  1888 ?        Ss   14:42   0:00 postgres: stats collector process  
root        79  2.0  0.0  21820  1984 ?        Ss   14:42   0:00 /bin/bash
root        84  0.0  0.0  19092  1296 ?        R+   14:42   0:00 ps aux

Anyway, for my project I use another image for postgresql: https://github.com/sameersbn/docker-postgresql. This one works fine.

If you look at your log output, the following lines appear towards the end:

local-postgres9.5 | server stopped
local-postgres9.5 |
local-postgres9.5 | PostgreSQL init process complete; ready for start up.

Apparently, stopping and restarting the Postgres server is part of the initialisation process. In fact, the second-to-last line says

local-postgres9.5 | LOG:  database system is ready to accept connections.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!