From d2219e85e22f02df879fc0077b581aa611ee3eaa Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Mon, 27 Mar 2017 08:18:25 +0200 Subject: [PATCH 1/4] 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/4] 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 From 7347b8ed7ee5457b39f0c8d384f82e489a4f1318 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 20 Oct 2017 23:06:45 +0200 Subject: [PATCH 3/4] Install gnupg for fetching keys first --- Dockerfile | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1c37c7..f451b71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,17 +5,13 @@ MAINTAINER Tim Sutton RUN export DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND noninteractive RUN dpkg-divert --local --rename --add /sbin/initctl -#RUN ln -s /bin/true /sbin/initctl - -# Use local cached debs from host (saves your bandwidth!) -# Change ip below to that of your apt-cacher-ng host -# Or comment this line out if you do not with to use caching -ADD 71-apt-cacher-ng /etc/apt/apt.conf.d/71-apt-cacher-ng +RUN apt-get -y update +RUN apt-get -y install gnupg #RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list # Add the PostgreSQL PGP key to verify their Debian packages. # It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc -RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 +RUN apt-key adv --keyserver hkps://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 # Add PostgreSQL's repository. It contains the most recent stable release # of PostgreSQL, ``9.5``. RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list @@ -27,9 +23,7 @@ RUN apt-get -y install ca-certificates rpl pwgen # We add postgis as well to prevent build errors (that we dont see on local builds) # on docker hub e.g. # The following packages have unmet dependencies: -# postgresql-9.3-postgis-2.1 : Depends: libgdal1h (>= 1.9.0) but it is not going to be installed -# Recommends: postgis but it is not going to be installed -RUN apt-get install -y postgresql-9.5-postgis-2.2 netcat +RUN apt-get install -y postgresql-9.5-postgis-2.2 # Open port 5432 so linked containers can see them EXPOSE 5432 From 0c4e78353454a71dd09791724c240c3330eedae9 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 20 Oct 2017 23:42:43 +0200 Subject: [PATCH 4/4] Fix key fetching --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f451b71..038de3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get -y install gnupg #RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list # Add the PostgreSQL PGP key to verify their Debian packages. # It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc -RUN apt-key adv --keyserver hkps://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 +RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 # Add PostgreSQL's repository. It contains the most recent stable release # of PostgreSQL, ``9.5``. RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list