Home:ALL Converter>Docker container stops right after starting Postgres DB

Docker container stops right after starting Postgres DB

Ask Time:2018-05-01T23:35:20         Author:Gerben Kranenborg

Json Formatter

I am working on setting up Postgres 9.5 AS in Docker, and got everything installed. The issue however is, when I start the Docker Container, it appears that Postgres starts at first, but then the Container stops right away. (it does not show up with a docker container ls.). When I overwrite the Container startup with --entrypoint sh, and manually start Postgres, it all works fine.

I also checked with docker logs <container-id>, but that does not give me any info at all.

The setup is like this :

Dockerfile :

ENTRYPOINT ["/opt/edb/9.5AS/bin/init.sh"]

init.sh :

su enterprisedb -c '/opt/edb/9.5AS/bin/pg_ctl start -D /opt/edb/9.5AS/data'

From my command prompt I run :

docker run -it -v pgdata:/opt/edb/9.5AS/data <image_name>

It almost looks like it does start, but as soon as the start process is done, the shell stops, and as a result the Container stops as well.

So how to get it so the Container starts, Postgres starts and everything stays running, preferable in detached mode of course?

Author:Gerben Kranenborg,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50119358/docker-container-stops-right-after-starting-postgres-db
yy