mirror of
https://github.com/wassname/docker-postgresql.git
synced 2026-08-12 12:00:50 +08:00
Merge branch 'tacodata-master'
This commit is contained in:
@@ -150,6 +150,23 @@ 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.
|
, 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.
|
||||||
|
|
||||||
|
For example,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --name postgresql -d \
|
||||||
|
-e 'PSQL_TRUST_LOCALNET=Y' \
|
||||||
|
sameersbn/postgresql:9.4
|
||||||
|
```
|
||||||
|
|
||||||
|
This has the effect of adding the following to the pg_hba.conf file:
|
||||||
|
|
||||||
|
```
|
||||||
|
host all all samenet trust
|
||||||
|
```
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
## Data Store
|
## Data Store
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ PG_CONFDIR="/etc/postgresql/${PG_VERSION}/main"
|
|||||||
PG_BINDIR="/usr/lib/postgresql/${PG_VERSION}/bin"
|
PG_BINDIR="/usr/lib/postgresql/${PG_VERSION}/bin"
|
||||||
PG_DATADIR="${PG_HOME}/${PG_VERSION}/main"
|
PG_DATADIR="${PG_HOME}/${PG_VERSION}/main"
|
||||||
|
|
||||||
|
# set this env variable to Y 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}
|
||||||
|
|
||||||
DB_NAME=${DB_NAME:-}
|
DB_NAME=${DB_NAME:-}
|
||||||
DB_USER=${DB_USER:-}
|
DB_USER=${DB_USER:-}
|
||||||
DB_PASS=${DB_PASS:-}
|
DB_PASS=${DB_PASS:-}
|
||||||
@@ -27,6 +32,12 @@ cat >> ${PG_CONFDIR}/postgresql.conf <<EOF
|
|||||||
listen_addresses = '*'
|
listen_addresses = '*'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
trust_local="host all all samenet trust"
|
||||||
|
if [ ${PSQL_TRUST_LOCALNET} = "Y" ]; then
|
||||||
|
echo "Enabling trust samenet in pg_hba.conf..."
|
||||||
|
echo ${trust_local} >> ${PG_CONFDIR}/pg_hba.conf
|
||||||
|
fi
|
||||||
|
|
||||||
# allow remote connections to postgresql database
|
# allow remote connections to postgresql database
|
||||||
cat >> ${PG_CONFDIR}/pg_hba.conf <<EOF
|
cat >> ${PG_CONFDIR}/pg_hba.conf <<EOF
|
||||||
host all all 0.0.0.0/0 md5
|
host all all 0.0.0.0/0 md5
|
||||||
|
|||||||
Reference in New Issue
Block a user