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

Allow "initdb.d" scripts to be executed instead of sourced #452

Merged
merged 1 commit into from
Jun 6, 2018

Conversation

tianon
Copy link
Member

@tianon tianon commented May 30, 2018

Closes #450

cc @willglynn (is this similar to the workaround you've applied in your own scripts?)

@willglynn
Copy link

willglynn commented May 30, 2018

@tianon Well… given an executable /docker-entrypoint-initdb.d/restore.sh containing:

#!/bin/sh -e
gunzip < /something | pg_restore

My expectation was that this would run in its own shell with set -e. This wasn't (and isn't) the case. My issue in #450 was caused by the shared environment changing to include set +o pipefail.

My workaround was to move this script to restore.sh.real and make restore.sh say:

#!/bin/sh -e
/docker-entrypoint-initdb.d/restore.sh.real

This runs my script in a separate shell, as expected, allowing the entrypoint script to change however it wants without affecting my restore script's operation. I'd rather it work that way out of the box, of course.

Compatibility is important, so I don't think the postgres images can just stop .ing scripts and start trying to execute them instead. Checking the provided shell script with test -x might be a suitable compromise: anyone who sets +x shouldn't be surprised when their script gets executed, and if that's a problem, they could mark it -x to revert back to the dot behavior.

@tianon
Copy link
Member Author

tianon commented May 30, 2018

Fair point, seems like a sane compromise. PR updated.

(One caveat is that this will mean any files bind-mounted from Windows will be executed instead of sourced.)

@tianon tianon changed the title Reset "pipefail" for initdb.d scripts" Allow "initdb.d" scripts to be executed instead of sourced May 30, 2018
@tianon tianon requested a review from yosifkit June 1, 2018 16:12
@yosifkit
Copy link
Member

yosifkit commented Jun 1, 2018

This seems sane and I am working to update the docs. Do we want to add the same functionality to MariaDB, MySQL, and Percona? They have had pipefail since Jan 2016 (docker-library/mysql#134, MariaDB/mariadb-docker#37, docker-library/percona#12).

@tianon
Copy link
Member Author

tianon commented Jun 1, 2018 via email

Copy link
Member

@yosifkit yosifkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, docs PR created: docker-library/docs#1247

@yosifkit yosifkit merged commit b927923 into docker-library:master Jun 6, 2018
@yosifkit yosifkit deleted the initdb-fails branch June 6, 2018 21:09
tianon added a commit to infosiftr/stackbrew that referenced this pull request Jun 8, 2018
- `drupal`: 8.5.4
- `ghost`: 1.24.1
- `golang`: 1.10.3, 1.9.7
- `mongo`: 4.0.0~rc4
- `owncloud`: add `unzip` (docker-library/owncloud#103)
- `postgres`: allow `initdb.d` scripts to be executed instead of sourced (docker-library/postgres#452)
- `tomcat`: remove jre9 (docker-library/tomcat#120)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants