Skip to content

Latest commit

 

History

History
 
 

PostgreSQL-9.3.5-PostGIS-2.1.7-GDAL-1.11.2-Patched

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

PostgreSQL 9.3.5, PostGIS 2.1.7, GDAL 1.11.2, Patched

WARNING: This image is deprecated. Use tag Awkward Aardvark instead.

Versions

This Dockerfile compiles the following software:

  • PostgreSQL 9.3.5;

  • GEOS 3.4.2;

  • Proj 4.9.1: patched with the spanish national grid for conversion between ED50 to ETRS89;

  • GDAL 1.11.2: also patched;

  • Postgis 2.1.7: patched as well, and with topology support.

Usage Pattern

Build the image directly from Git (this can take a while, don't forget to checkout the right branch):

cd gitfolder

docker build -t="geographica/postgis:postgresql-9.3.5-postgis-2.1.7-gdal-1.11.2-patched" .

or pull it from Docker Hub:

docker pull geographica/postgis:postgresql-9.3.5-postgis-2.1.7-gdal-1.11.2-patched

The image uses several environment variables. Refer to the Dockerfile for a complete list. The most important one is POSTGRES_PASSWD, the password for the user POSTGRES.

The image exposes port 5432 and a volume designated by enviroment variable POSTGRES_DATA_FOLDER. In a production enviroment, create containers this way:

export PGPASSWD="md5"$(printf '%s' "password_here" "postgres" | md5sum | cut -d ' ' -f 1) && \
docker run -d -P --name ageworkshoptestpg -e "POSTGRES_PASSWD=${PGPASSWD}" \
geographica/postgis:postgresql-9.3.5-postgis-2.1.7-gdal-1.11.2-patched 

This generates a MD5 hashed password for the user postgres, hidden even to the docker inspect command. Keep in mind that to provide a MD5-hashed password to PostgreSQL it has to be the hash of passwordusername and be prefixed by md5.

The image creates containers that initializes automatically a datastore, setting the password for user postgres.

Executing psql Scripts on Start Up

The image can run psql scripts on container's start up. To do so, put scripts inside the container (via a child container image that ADD them from the Dockerfile or mounting a volume) and configure the PSQL_SCRIPTS environment variable. This variable can contain full paths to psql scripts separated by semicolons (;) that will be executed in order on container startup. For example:

export PGPASSWD="md5"$(printf '%s' "password_here" "postgres" | md5sum | cut -d ' ' -f 1) && \
docker run -d -P --name ageworkshoptestpg -e "POSTGRES_PASSWD=${PGPASSWD}" \
-v /localscripts/:/psql_scripts/ \
-e "PSQL_SCRIPTS=/psql_scripts/script1.sql;/psql_scripts/script2.sql" \
geographica/postgis:postgresql-9.3.5-postgis-2.1.7-gdal-1.11.2-patched 

script1.sql and script2.sql will be executed on container startup.

Killing the Container

This container will handle signals send to it with docker kill properly, so the database is shut down proper and tidily. Thus:

  • SIGTERM signals for a smart shutdown, waiting for all connections and transactions to be finished. The server won't allow for new connections, thou:
pg_ctl -D . stop -m smart

docker kill -s SIGTERM containername
  • SIGINT signals for fast shutdown. The server will abort current transactions and disconnect users, but will exit nicely otherwise;
pg_ctl -D . stop -m fast

docker kill -s SIGINT containername
  • SIGQUIT signals for immediate shutdown. This will leave the database in a improper state and lead to recovery on next startup:
pg_ctl -D . stop -m immediate

docker kill -s SIGQUIT containername