Skip to content

Add "DOCKER_INITDB_EXTRA_SQL" environment variable - #947

Closed
tianon wants to merge 1 commit into
docker-library:masterfrom
infosiftr:initdb-extra-sql-env
Closed

tianon wants to merge 1 commit into
docker-library:masterfrom
infosiftr:initdb-extra-sql-env

Conversation

@tianon

@tianon tianon commented Apr 6, 2022

Copy link
Copy Markdown
Member

@tianon
tianon requested a review from yosifkit April 6, 2022 22:42
@yosifkit

Copy link
Copy Markdown
Member

We try to add as few "extra" features as possible and I think this one isn't really necessary. We already have the ability to run arbitrary SQL and shell scripts on first initialization. I think this would set a precedent for similar requests in MySQL and friends. I would be open to POSTGRES_SUPERUSER (#175 (comment)), since creating a root/super user along with a limited user already exists for MySQL and friends.

The difference in the docker run lines don't seem that drastic. If users are in an environment where bind-mounts, config maps, or custom images are difficult or not allowed, then a simple command change is enough to have the same functionality. I'm fairly certain that all our push back in other images to force command argument customization and not just environment variables, means that they should all support this.

$ # with proposed change
$ docker run -d -e DOCKER_INITDB_EXTRA_SQL="really complex sql; things;" -e ... mysql:8

$ # without proposed change
$ docker run -d -e EXTRA_SQL='really complex sql; things;' -e ... mysql:8 sh -c 'echo "$EXTRA_SQL" > /docker-entrypoint-initdb.d/00-custom.sql && exec docker-entrypoint.sh mysql'
$ # could even skip the environment variable altogether
$ docker run -d -e ... mysql:8 sh -c 'echo "really complex sql; things;" > /docker-entrypoint-initdb.d/00-custom.sql && exec docker-entrypoint.sh mysql'

@tianon tianon closed this May 13, 2022
@tianon
tianon deleted the initdb-extra-sql-env branch May 13, 2022 21:47
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.

2 participants