Public Repository

Last pushed: 2 years ago
Short Description
Official Postgres image (9.4) creating a non-postgres user as the owner of non-postgres database
Full Description

My need is : When I run an image for which I provide a "non-postgres-user" name and "non-postgres-database" name, I want to have that created user as OWNER of that created database. For that purpose I have used the docker file of the official image of Postgres (9.4). And I have made a little modification in the entrypoint script "docker-entrypoint.sh" by adding the following lines after the "non-postgres-user" and the "non-postgres-database" creation :

Make the NON-postgres-DB owned by NON-postgres-USER

if ([ "$POSTGRES_DB" != 'postgres' ] && [ "$POSTGRES_USER" != 'postgres' ]); then
psql --username postgres <<-EOSQL
ALTER DATABASE "$POSTGRES_DB" OWNER TO "$POSTGRES_USER";
EOSQL
echo
fi

Docker Pull Command
Owner
nikkine