Skip to content

Instantly share code, notes, and snippets.

@rasputnik
Created January 14, 2014 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasputnik/8425116 to your computer and use it in GitHub Desktop.
Save rasputnik/8425116 to your computer and use it in GitHub Desktop.
postgresql 9.3 (transient) Dockerfile on centos6.
postgresql-9:$ cat Dockerfile
# postgresql 9 on centos 6.5
#
# docker build -t 'your/pg' <thisfile>
#
# then run with:
# docker run -P -d your/pg
# tweakables are the 'ENV' lines further down
# (if they were higher up they'd blow the cache)
FROM saltstack/centos-6-minimal
MAINTAINER Dick Davies <dick@hellooperator.net>
# TODO: fix locale! not allowing UTF-8 and think it's this 'minimal' image
# add postgresql.org repo
RUN yum install -y http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
# install postgres rpms
RUN yum install -y postgresql93-server postgresql93-contrib
# NB: transient! might want to map volumes, etc.
ENV PGDATA /pgdata
# initialize
RUN mkdir $PGDATA
RUN chown postgres $PGDATA
RUN su -c - postgres /usr/pgsql-9.3/bin/initdb
# open up tcp access
RUN echo "host all all 0.0.0.0/0 md5" > $PGDATA/pg_hba.conf
# needed to createuser below
RUN echo "local all postgres trust" >> $PGDATA/pg_hba.conf
# superuser account
ENV SUPERUSER god
ENV SUPERPASS godmode
# fire up db, create superuser, shut down
RUN su -c - postgres "/usr/pgsql-9.3/bin/pg_ctl -w start && echo create role $SUPERUSER SUPERUSER LOGIN PASSWORD \'$SUPERPASS\' | psql && /usr/pgsql-9.3/bin/pg_ctl -w stop"
EXPOSE 5432
USER postgres
# listen on network, log to stdout
ENTRYPOINT ["/usr/pgsql-9.3/bin/postgres", "-i", "-c", "logging_collector=off"]
@larrycai
Copy link

larrycai commented Jul 3, 2014

did you fix locale problem ? in official centos:latest (6.5), the problem exists as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment