From d2219e85e22f02df879fc0077b581aa611ee3eaa Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Mon, 27 Mar 2017 08:18:25 +0200 Subject: [PATCH 1/2] 9.5 2.2 (#61) * Allow changing the default database name (#50) * Allow changing the default database name (#50) * Allow changing the default database name (#50) (#52) * Commented out legacy scripts since it seems they are removed in 2.2 * Added more options to convenience run script * Added missing l from getopts * Added missing l from getopts --- README.md | 4 +++- run-postgis-docker.sh | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 798d8f6..7bb25e1 100644 --- a/README.md +++ b/README.md @@ -112,14 +112,16 @@ OPTIONS: -h Show this message -n Container name -v Volume to mount the Postgres cluster into + -l local port (defaults to 25432) -u Postgres user name (defaults to 'docker') -p Postgres password (defaults to 'docker') + -d database name (defaults to 'gis') ``` Example usage: ``` -./run-postgis-docker.sh -v /tmp/foo/ -n postgis -u foo -p bar +./run-postgis-docker.sh -p 6789 -v /tmp/foo/ -n postgis -u foo -p bar ``` diff --git a/run-postgis-docker.sh b/run-postgis-docker.sh index 166e5bd..c3401b5 100755 --- a/run-postgis-docker.sh +++ b/run-postgis-docker.sh @@ -15,12 +15,14 @@ OPTIONS: -h Show this message -n Container name -v Volume to mount the Postgres cluster into + -l local port (defaults to 25432) -u Postgres user name (defaults to 'docker') -p Postgres password (defaults to 'docker') + -d database name (defaults to 'gis') EOF } -while getopts ":h:n:v:u:p:" OPTION +while getopts ":h:n:v:l:u:p:d:" OPTION do case $OPTION in n) @@ -29,12 +31,18 @@ do v) VOLUME=${OPTARG} ;; + l) + LOCALPORT=${optarg} + ;; u) - PGUSER=${OPTARG} + PGUSER=${optarg} ;; p) PGPASSWORD=${OPTARG} ;; + p) + DATADIR=${OPTARG} + ;; *) usage exit 1 @@ -43,12 +51,19 @@ do done -if [[ -z $VOLUME ]] || [[ -z $CONTAINER_NAME ]] || [[ -z $PGUSER ]] || [[ -z $PGPASSWORD ]] +if [[ -z $VOLUME ]] || [[ -z $CONTAINER_NAME ]] || [[ -z $PGUSER ]] || [[ -z $PGPASSWORD ]] || [[ -z $DATADIR ]] || [[ -z $LOCALPORT ]] + then usage exit 1 fi +if [[ ! -z $LOCALPORT]] +then + LOCALPORT=${LOCALPORT} +else + LOCALPORT=25432 +fi if [[ ! -z $VOLUME ]] then VOLUME_OPTION="-v ${VOLUME}:/var/lib/postgresql" @@ -70,8 +85,10 @@ CMD="docker run --name="${CONTAINER_NAME}" \ --restart=always \ -e POSTGRES_USER=${PGUSER} \ -e POSTGRES_PASS=${PGPASSWORD} \ + -e DATADIR=${DATADIR} \ -d -t \ ${VOLUME_OPTION} \ + -p "${LOCALPORT}:5432" \ kartoza/postgis /start-postgis.sh" echo 'Running\n' From 1aa1b0de521d78049690900c0209ea52dc8e786a Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Mon, 25 Sep 2017 04:41:44 +0200 Subject: [PATCH 2/2] allow connection when using docker compose (#65) see https://github.com/docker/compose/issues/4336 and https://github.com/kartoza/docker-postgis/issues/40 --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index f10a5c8..a8a2627 100755 --- a/setup.sh +++ b/setup.sh @@ -6,6 +6,7 @@ CONF="/etc/postgresql/9.5/main/postgresql.conf" # Restrict subnet to docker private network echo "host all all 172.17.0.0/16 md5" >> /etc/postgresql/9.5/main/pg_hba.conf +echo "host all all 172.18.0.0/16 md5" >> /etc/postgresql/9.5/main/pg_hba.conf # And allow access from DockerToolbox / Boottodocker on OSX echo "host all all 192.168.0.0/16 md5" >> /etc/postgresql/9.5/main/pg_hba.conf # Listen on all ip addresses