Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to script adding a new User/Database to an existing database instance? #945

Closed
nodje opened this issue Mar 27, 2022 · 2 comments
Closed
Labels
question Usability question, not directly related to an error with the image

Comments

@nodje
Copy link

nodje commented Mar 27, 2022

I must be the nth person asking for this, but I can find a solution for this anywhere.

Since, as per the doc, Warning: scripts in /docker-entrypoint-initdb.d are only run if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup,it seems there is no way to add a script to /docker-entrypoint-initdb.d to create a new User/Database couple when you add, say a new container to a docker-compose file and want to share a single postgres instance.

Or am I understanding this wrong?

In anycase, in my tests I get a PostgreSQL Database directory appears to contain a database; Skipping initialization in the logs, confirming the behaviour.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Mar 28, 2022
@wglambert
Copy link

You'd have to do it manually or devise some automated connection to the database to execute the script, the entrypoint won't modify existing data

@tianon
Copy link
Member

tianon commented Mar 28, 2022

See #929, #173, #821, #191 (to link a few similar issues) -- hopefully one of these has some helpful clues for helping you implement what you're looking for 👍

@tianon tianon closed this as completed Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants