From 0c80030b44c59a714c7ec2dd643704cbd3acb4d4 Mon Sep 17 00:00:00 2001 From: Mike Dillon Date: Fri, 21 Aug 2015 23:17:18 -0700 Subject: [PATCH 1/2] Expand documentation of postgres initdb logic * Explain the execution order of initdb extension files * Document that *.sql scripts are run as $POSTGRES_USER * Recommend running psql commands inside *.sh scripts as $POSTGRES_USER --- postgres/content.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgres/content.md b/postgres/content.md index 69e6e0138bc6..39caa19b2351 100644 --- a/postgres/content.md +++ b/postgres/content.md @@ -51,9 +51,9 @@ This optional environment variable can be used to define another location - like # How to extend this image -If you would like to do additional initialization in an image derived from this one, add a `*.sql` or `*.sh` script under `/docker-entrypoint-initdb.d` (creating the directory if necessary). After the entrypoint calls `initdb` to create the default `postgres` user and database, it will run any `*.sql` files and source any `*.sh` script found in that directory to do further initialization before starting the service. +If you would like to do additional initialization in an image derived from this one, add one or more `*.sql` or `*.sh` scripts under `/docker-entrypoint-initdb.d` (creating the directory if necessary). After the entrypoint calls `initdb` to create the default `postgres` user and database, it will run any `*.sql` files and source any `*.sh` scripts found in that directory to do further initialization before starting the service. These initialization files will be executed in sorted name order as defined by the current locale, which defaults to `en_US.utf8`. Any `*.sql` files will be executed by `POSTGRES_USER`, which defaults to the `postgres` superuser. It is recommended that any `psql` commands that are run inside of a `*.sh` script be executed as `POSTGRES_USER` by using the `--username "$POSTGRES_USER"` flag. This user will be able to connect without a password due to the presence of `trust` authentication for Unix socket connections made inside the container. -You can also extend the image with a simple `Dockerfile` to set the locale. The following example will set the default locale to `de_DE.utf8`: +You can also extend the image with a simple `Dockerfile` to set a different locale. The following example will set the default locale to `de_DE.utf8`: ```dockerfile FROM postgres:9.4 From 4106a4c4f5a8ab8581421909a34449557de2cf6f Mon Sep 17 00:00:00 2001 From: Mike Dillon Date: Fri, 21 Aug 2015 23:23:13 -0700 Subject: [PATCH 2/2] Break up the paragraphs in initdb explanation --- postgres/content.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/postgres/content.md b/postgres/content.md index 39caa19b2351..ce33e16ac3de 100644 --- a/postgres/content.md +++ b/postgres/content.md @@ -51,7 +51,9 @@ This optional environment variable can be used to define another location - like # How to extend this image -If you would like to do additional initialization in an image derived from this one, add one or more `*.sql` or `*.sh` scripts under `/docker-entrypoint-initdb.d` (creating the directory if necessary). After the entrypoint calls `initdb` to create the default `postgres` user and database, it will run any `*.sql` files and source any `*.sh` scripts found in that directory to do further initialization before starting the service. These initialization files will be executed in sorted name order as defined by the current locale, which defaults to `en_US.utf8`. Any `*.sql` files will be executed by `POSTGRES_USER`, which defaults to the `postgres` superuser. It is recommended that any `psql` commands that are run inside of a `*.sh` script be executed as `POSTGRES_USER` by using the `--username "$POSTGRES_USER"` flag. This user will be able to connect without a password due to the presence of `trust` authentication for Unix socket connections made inside the container. +If you would like to do additional initialization in an image derived from this one, add one or more `*.sql` or `*.sh` scripts under `/docker-entrypoint-initdb.d` (creating the directory if necessary). After the entrypoint calls `initdb` to create the default `postgres` user and database, it will run any `*.sql` files and source any `*.sh` scripts found in that directory to do further initialization before starting the service. + +These initialization files will be executed in sorted name order as defined by the current locale, which defaults to `en_US.utf8`. Any `*.sql` files will be executed by `POSTGRES_USER`, which defaults to the `postgres` superuser. It is recommended that any `psql` commands that are run inside of a `*.sh` script be executed as `POSTGRES_USER` by using the `--username "$POSTGRES_USER"` flag. This user will be able to connect without a password due to the presence of `trust` authentication for Unix socket connections made inside the container. You can also extend the image with a simple `Dockerfile` to set a different locale. The following example will set the default locale to `de_DE.utf8`: