I can add additionally users and database with psql as soon as the postgres server is started. With this docker image the binary is started via docker-entrypoint.sh How can I automate this within my own Dockerfile?
I assume I would need to write a script that I call within my Dockerfile as an entrypoint. This script would need to start the database server, then execute the commands with psqland afterwards stop the db server again and let the original docker-entrypoint.sh entrypoint taken place. However I'm not sure: how can I start and stop a postgres server manually within my custom script with this postgres docker image?
thanks
m
Ok I think I simply need to hack into the docker-entrypoint.sh and replace the original!
See https://github.com/docker-library/postgres/blob/bfca9b8a92a99ccfc8f04933b7ecc29a108c7f49/docker-entrypoint.sh#L63-L67 for an easy way to accomplish this without replacing the _entire_ entrypoint script. :+1:
Is it possible to do it using SQL script inside /docker-entrypoint-initdb.d ?
@uksus70 per comment https://github.com/docker-library/postgres/pull/240#issuecomment-314228559 it is possible, yes (I didn't test though)
Since this issue seems unrelated to any errors in the image itself, and being a year without further comment, I'm going to prune the issue.
If you believe this to be in error then let me know and I'll re-open it
Given that the issue is more of a usability question, it would be more suited for the Docker Community Forums, the Docker Community Slack, or Stack Overflow.
Most helpful comment
https://github.com/docker-library/postgres/pull/240