-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Initilizations scripts in docker-entrypoint-initdb.d cannot be executed to existing lock file #78
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
Comments
Hello ! I'm running into the same troubles after the recent update. The structure of my project: $ tree .
.
├── build
├── Dockerfile
├── initialize.sh
├── launch
└── sql
├── 01_mail.sql
├── 11_get_list_stored_procedures.sql
├── 12_get_unseen_messages.sql
├── 13_create_email.sql
├── 14_update_message_timestamp.sql
├── 20_triggers.sql
└── 90_stubdata.sql initialize.sh #!/bin/bash
set -e
set -x
echo "******PostgreSQL initialisation******"
echo "Starting postgres"
gosu postgres pg_ctl -w start
for f in sql/*.sql; do
echo "Executing $f"
gosu postgres psql -h localhost -p 5432 -U postgres -d $POSTGRES_DB -a -f $f
done
echo "Stopping Postgres"
gosu postgres pg_ctl stop
echo "Stopped postgres"
echo "******Initialisation finished******" Log output:
I had to replace |
@vitalyisaev2 You shouldn't need your |
@mmaczka See the discussion at #75. Basically, you'll need to replace cf. postgis/docker-postgis@bf8bfec or aidanlister/postgres-hstore@22fa0d1 for a couple projects that have been updated to fix the breaking changes. |
What is the best way to create new database and new user, now after this all changes? I'd prefer to use SQL scripts but I need to pass user name / password via env vars to the container but SQL scripts don't understand environment variables. |
@mmarzantowicz you don't have to create the user using the passed envs, you are free to use your sql to create them. If you need the sql run by something than the env supplied user (or the |
Especially since Postgres upstream discourages the use of "--single" pretty
heavily, and some of the core developers wonder why it even still exists at
all.
|
Thanks! I've managed to create user/db "the new way" quite easily: I just use One thing I don't understand is why |
In the default configuration, local connections for the "postgres" user are
trusted implicitly (see default "pg_hba.conf" contents).
|
I stumbled upon this issue after discovering that --single created the locking issue on the current 9.4 tag / image_id: 730d1d72bda2 on a 2nd machine I tried deploying to, where my dev machine had the --single enabled with no locking but that was because I was on the 9.4 tag / image_id: f33438ff9aef which was from 2 weeks ago and it had not been updated. I understand that images will be updated in a public repo all the time, and that the best way for me to ensure consistency across deployments is to roll my own image and distribute it to my machines accordingly, but IMO this defeats the purpose of tagging in the first place. I guess my question boils down to, is this something we should take up with Docker to support something along the lines of image:tag:commit or should postgres (and other projects) be using some other sort of semantic versioning relevant to docker images to reflect the changes and not break things in these scenarios? |
postgres:9.4 now doesn’t support --single anymore: docker-library/postgres#78
@md5 thank you, that fixed my problem |
“--single” does not work anymore: docker-library/postgres#78
- The new initdb logic of the postgres container broke the --single setup of our container. As the --single switch is deprecated by the postgres folks, this is the cleaner way anyway. - Simplifying the check for an existing gnuhealth database. Refs: - #2 - docker-library/postgres#75 - docker-library/postgres#78
Hello, I have a question. If I want to execute multiple sql files in order in /docker-entrypoint-initdb.d/, how can I do that? even though I add a shell script to run sqls in order, its not running shell script first. |
It will execute files in alphabetical order, so if you want to run several
scripts, simply name them such that they sort in the order you want them to
run.
|
Closing given that the original issue here is resolved. 👍 |
My initialisation scripts from /docker-entrypoint-initdb.d/ ceased to work with latest update
db_1 | /docker-entrypoint.sh: running /docker-entrypoint-initdb.d/setup-database.sh
db_1 | FATAL: lock file "postmaster.pid" already exists
db_1 | HINT: Is another postmaster (PID 54) running in data directory "/var/lib/postgresql/data"?
This fetaure (any my scripts) were working fine for previous few months - only latest update introduced some breaking changes
The text was updated successfully, but these errors were encountered: