Sign inSign up

jackyyu/postgresql

By jackyyu

•Updated over 10 years ago

PostgreSQL 9.5

Image
0

150

jackyyu/postgresql repository overview

FROM ubuntu:14.04 MAINTAINER [email protected]⁠

ENV POSTGRESQL_VERSION=9.5

⁠Add the PostgreSQL PGP key to verify their Debian packages.

RUN
apt-get update &&
apt-get install -y wget &&
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc⁠ | sudo apt-key add - &&
apt-get update &&
echo "deb http://apt.postgresql.org/pub/repos/apt/⁠ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list &&
apt-get update &&
apt-get install -y python-software-properties software-properties-common
postgresql-${POSTGRESQL_VERSION} postgresql-client-${POSTGRESQL_VERSION}
postgresql-contrib-${POSTGRESQL_VERSION}

⁠Run the rest of the commands as the postgres user created by the postgres-9.3 package when it was apt-get installed

USER postgres

⁠Create a PostgreSQL role named docker with docker as the password and

⁠then create a database docker owned by the docker role.

⁠Note: here we use &&\ to run commands one after the other - the \

⁠allows the RUN command to span multiple lines.

RUN /etc/init.d/postgresql start &&
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&
createdb -O docker docker

⁠Adjust PostgreSQL configuration so that remote connections to the

⁠database are possible.

RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/${POSTGRESQL_VERSION}/main/pg_hba.conf

⁠And add listen_addresses to /etc/postgresql/${POSTGRESQL_VERSION}/main/postgresql.conf

RUN echo "listen_addresses='*'" >> /etc/postgresql/${POSTGRESQL_VERSION}/main/postgresql.conf

⁠Expose the PostgreSQL port

EXPOSE 5432

⁠Add VOLUMEs to allow backup of config, logs and databases

VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]

⁠Set the default command to run when starting the container

CMD /usr/lib/postgresql/${POSTGRESQL_VERSION}/bin/postgres -D /var/lib/postgresql/${POSTGRESQL_VERSION}/main -c config_file=/etc/postgresql/${POSTGRESQL_VERSION}/main/postgresql.conf

Tag summary

Content type

Image

Digest

Size

121 MB

Last updated

over 10 years ago

docker pull jackyyu/postgresql:9.5