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

Sending RUN ["docker-entrypoint.sh", "postgres", "--version"] output to the console during the build #718

Closed
doraemoncito opened this issue Apr 19, 2020 · 2 comments

Comments

@doraemoncito
Copy link

Apologies if this question has been asked before. Up until version 10.10 you could see the output of the command in a Docker file that inherited from the postgres:10.10-alpine image. E.g. this Dockerfile (cut for brevity):

FROM postgres:10.10-alpine
RUN ["docker-entrypoint.sh", "postgres", "--version"]

would output something like this:

[INFO]  ---> fd92132d5c20
[INFO] Step 10/10 : RUN ["docker-entrypoint.sh", "postgres", "--version"]
[INFO] 
[INFO]  ---> Running in 2a64e24f8df8
[INFO] The files belonging to this database system will be owned by user "postgres".
[INFO] This user must also own the server process.
[INFO] 
[INFO] The database cluster will be initialized with locale "en_US.utf8".
[INFO] The default database encoding has accordingly been set to "UTF8".
[INFO] The default text search configuration will be set to "english".
...

Starting at 10.11 the output no longer appears in the console during the build. . E.g. this Dockerfile (again cut for brevity):

FROM postgres:12-alpine
RUN ["docker-entrypoint.sh", "postgres", "--version"]

Generates this output instead:

[INFO]  ---> 9e1c212f6bcc
[INFO] Step 10/10 : RUN ["docker-entrypoint.sh", "postgres", "--version"]
[INFO] 
[INFO]  ---> Running in aa64abc39508
[INFO] postgres (PostgreSQL) 12.2
[INFO] Removing intermediate container aa64abc39508
[INFO]  ---> e7eeb9d68edc
[INFO] Successfully built e7eeb9d68edc

Is there any way of getting the earlier 10.10 entry point output behaviour in later versions of the Docker image?

@tianon
Copy link
Member

tianon commented Apr 20, 2020

The output no longer appears because postgres --version no longer has the side effect of initializing a database (since the arguments passed to postgres are now passed to the temporary daemon as well, so it would've completely broken instead of doing what an interactive user would expect, so we changed it to explicitly detect several flags):

# check arguments for an option that would cause postgres to stop
# return true if there is one
_pg_want_help() {
local arg
for arg; do
case "$arg" in
# postgres --help | grep 'then exit'
# leaving out -C on purpose since it always fails and is unhelpful:
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
-'?'|--help|--describe-config|-V|--version)
return 0
;;
esac
done
return 1
}

See #496 -- this is now possible to accomplish directly without hacks/workarounds like sed or --version. 👍

@tianon tianon closed this as completed Apr 20, 2020
@doraemoncito
Copy link
Author

https://github.com/docker-> See #496 -- this is now possible to accomplish directly without hacks/workarounds like sed or --version. 👍

Brilliant, that's exactly what I was looking for. Thank you.

doraemoncito added a commit to doraemoncito/postgresql-container that referenced this issue Apr 20, 2020
doraemoncito added a commit to doraemoncito/postgresql-container that referenced this issue Apr 27, 2020
* Initial revision

* Updated docker image to user PostgreSQL 12 and Java 11.

* Made Dockerfile compatible with previous versions of the base image. e.g. postgres:1X-alpine

* Added link to question about sending the output of the Docker build to the console.

* Removed --version hack from the RUN command used to create the database.  See docker-library/postgres#718 for more details.

* Added custom entry point.

* Updated flyway configuration files and changed entry point to prevent silent migration failures.
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

No branches or pull requests

2 participants