Skip to content
vanpeerdevelopment edited this page Jan 14, 2016 · 2 revisions
# Dockerfile
FROM postgres:9.5.0 

ENV POSTGRES_USER=postgres 
ENV POSTGRES_PASSWORD=secret 
ENV POSTGRES_DB=dws

COPY Vx.x_init.sh /docker-entrypoint-initdb.d/
# Vx.x_init.sh
psql -U $POSTGRES_USER -w 
     -c "CREATE USER dws WITH ENCRYPTED PASSWORD 'dws'" dws
psql -U $POSTGRES_USER -w 
     -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dws" dws 

The DWS database image is based on the official PostgreSQL 9.5.0 docker image.

The following environment variables can be used to configure the image.

  • POSTGRES_USER
    Name of the superuser to create, postgres if not defined.
  • POSTGRES_PASSWORD
    Password for the created superuser, mysecretpassword if not defined.
  • POSTGRES_DB
    Name of the database to create, POSTGRES_USER value if not defined.
  • PGDATA
    Location of the databse files, /var/lib/postgresql/data if not defined. initdb

When the superuser and database are created, sql files and scripts in /docker-entrypoint-initdb.d folder will be executed to further configure the database before starting the service. The files will be executed in alphabetical order. The sql files will be executed by POSTGRES_USER. It is best to run all psql as POSTGRES_USER because it can connect without a password in the container.

Clone this wiki locally