Public Repository

Last pushed: a month ago
Short Description
Posgres (oficial) based image built with supervisor and confd to allow dynamic configuration updates
Full Description

PostgreSQL docker container insightsoftware/postgres which includes supervisor and confd to allow dynamic configuration updates.

  • Based on postgres:9.5 (official PostgreSQL docker image)
  • Includes confd to configure services
  • Includes supervisor to ensure services are running.

ENV VARIABLES

POSTGRES_USER

The default user for PostgreSQL (e.g. "postgres").

POSTGRES_PASSWORD

The password for the default user.

CONFD_BACKEND

The backend confd will use to update de configuration templates. The default is set to environment variables (i.e. "env").

POSTGRESQL_CONFIG

Environment variable used by confd to update postgresql.conf (see the official documentation for more details about this file). Some configurations can be set directly (i.e. "max_connections", "listen_addresses", "authentication_timeout", "statement_timeout") while other can be added as key value pairs through the "extra_configs" key.

Syntax:
{  
    "max_connections":"<maximum number of connections>",  
    "listen_addresses":"<addesses to listen to>",  
    "authentication_timeout":"<authentication timeout>",  
    "statement_timeout":"<statement timeout>",  
    "extra_configs": [  
        { "key": "<key1>", "value": "<value1>" },  
        { "key": "<key2>", "value": "<value2>" },   
        <other key value pairs>  
    ]  
}
Example usage:
docker run <parameters>  
-e POSTGRESQL_CONFIG='{ "max_connections": "50", "listen_addresses": "*", "authentication_timeout": "1min", "statement_timeout": "60000" }'  
<other parameters>  
insightsoftware/postgres

PG_HBA_CONFIG

Environment variable used by confd to update pg_hba.conf (see the official documentation for more details about the configuration fields).

Syntax:
{ 
    configs: [
        {
            "type": "<connection type>",
            "database": "<database>",
            "user": "<user>",
            "address": "<addresses allowed>",
            "method": "<authentication method>"
        },
        <extra configurations>
    ]
}
Example usage:
docker run <parameters>  
    -e PG_HBA_CONFIG='{"configs": [{"type": "host", "database": "all", "user": "all", "address": "0.0.0.0/0", "method": "md5" }]}'
    <other parameters>  
    insightsoftware/postgres

USAGE

Basic Command

You can run the container, accepting connections from all ip addresses, using the following command:

docker run -d --name insight_postgres \
    -e POSTGRES_USER='postgres' \
    -e POSTGRES_PASSWORD='password' \
    -e POSTGRESQL_CONFIG='{ "max_connections": "50", "listen_addresses": "*", "authentication_timeout": "1min", "statement_timeout": "60000" }' \
    -e PG_HBA_CONFIG='{"configs": [{"type": "host", "database": "all", "user": "all", "address": "0.0.0.0/0", "method": "md5" }]}' \
    -p 5432:5432 \
    -v /var/lib/insight_postgres/data/:/var/lib/postgresql/data \
    insightsoftware/postgres

Dockerfile

FROM postgres:9.5

MAINTAINER Hubble Infrastructure <hubble.infrastructure@insighsoftware.com>

ENV CONFD_VERSION 0.12.0-alpha3
ENV CONFD_SHA1 437524fe3334bd9d0424ed0ece265472e789d19e
ENV PYTHON_VERSION=2.7.9-1
ENV PY_PIP_VERSION=1.5.6-5
ENV PYTHON_PKG_VERSION=5.5.1-1
ENV PYTHON_SETUPTOOLS_VERSION=5.5.1-1
ENV SUPERVISOR_VERSION=3.0r1-1
ENV SUPERVISOR_CONF='{"programs": [{"program": "postgresql", "command": "/docker-entrypoint.sh postgres", "stopsignal":"SIGINT", "priority": "1", "autostart": "true", "autorestart": "true", "startsecs": "0", "stdout_logfile": "/var/log/supervisor/postgresql.log"}]}'
ENV CONFD_BACKEND='env'

ENV PGDATA='/var/lib/postgresql/data'

#Install confd and Supervisor
RUN set -ex && \
    apt-get update && \
    apt-get -y install wget ca-certificates && \
    wget https://github.com/kelseyhightower/confd/releases/download/v$CONFD_VERSION/confd-$CONFD_VERSION-linux-amd64 -O /usr/local/bin/confd && \ 
    chmod +x /usr/local/bin/confd && \
    mkdir /var/log/supervisor && \
    apt-get -y install python=$PYTHON_VERSION python-pkg-resources=$PYTHON_PKG_VERSION python-setuptools=$PYTHON_SETUPTOOLS_VERSION supervisor=$SUPERVISOR_VERSION && \
    rm -rf /etc/supervisor/supervisor.conf && \
    apt-get -y remove wget ca-certificates && \
    apt-get -y clean && apt-get -y autoremove

#Configure confd
COPY ./confd /etc/confd

#Configure Supervisor
COPY ./supervisor /etc/supervisor

########### CUSTOM INSTRUCTIONS ###########

COPY initConfd.sh /

RUN chmod +x /initConfd.sh

EXPOSE 5432

####### END OF CUSTOM INSTRUCTIONS ########

#Entrypoint
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Docker Pull Command
Owner
insightsoftware