start: use true/false for PSQL_TRUST_LOCALNET configuration

This commit is contained in:
Sameer Naik
2015-02-08 12:03:48 +05:30
parent 8ed8d2e0f5
commit 5d4cff076a
2 changed files with 6 additions and 7 deletions
+3 -4
View File
@@ -150,18 +150,17 @@ docker run --name postgresql -d \
, will create a user *dbuser* with the password *dbpass*. It will also create a database named *dbname* and the *dbuser* user will have full access to the *dbname* database.
The PSQL_TRUST_LOCALNET environment variable can be used to configure postgres to trust connections on the same network. This
is handy for other containers to connect without authentication. To enable this behavior, set PSQL_TRUST_LOCALNET to Y.
The `PSQL_TRUST_LOCALNET` environment variable can be used to configure postgres to trust connections on the same network. This is handy for other containers to connect without authentication. To enable this behavior, set `PSQL_TRUST_LOCALNET` to `true`.
For example,
```bash
docker run --name postgresql -d \
-e 'PSQL_TRUST_LOCALNET=Y' \
-e 'PSQL_TRUST_LOCALNET=true' \
sameersbn/postgresql:9.4
```
This has the effect of adding the following to the pg_hba.conf file:
This has the effect of adding the following to the `pg_hba.conf` file:
```
host all all samenet trust
+3 -3
View File
@@ -6,10 +6,10 @@ PG_CONFDIR="/etc/postgresql/${PG_VERSION}/main"
PG_BINDIR="/usr/lib/postgresql/${PG_VERSION}/bin"
PG_DATADIR="${PG_HOME}/${PG_VERSION}/main"
# set this env variable to Y to enable a line in the
# set this env variable to true to enable a line in the
# pg_hba.conf file to trust samenet. this can be used to connect
# from other containers on the same host without authentication
PSQL_TRUST_LOCALNET=${PSQL_TRUST_LOCALNET:N}
PSQL_TRUST_LOCALNET=${PSQL_TRUST_LOCALNET:false}
DB_NAME=${DB_NAME:-}
DB_USER=${DB_USER:-}
@@ -33,7 +33,7 @@ listen_addresses = '*'
EOF
trust_local="host all all samenet trust"
if [ ${PSQL_TRUST_LOCALNET} = "Y" ]; then
if [ ${PSQL_TRUST_LOCALNET} = "true" ]; then
echo "Enabling trust samenet in pg_hba.conf..."
echo ${trust_local} >> ${PG_CONFDIR}/pg_hba.conf
fi