Im trying to create a Dockerfile from the postgres image. The repo says that initialization should be handled by placing a shell script in /docker-entrypoint-initdb.d/. I pu
@a_horse_with_no_name got me on the right track with his comment. I decided to ditch the single user mode even if it was "recommended". Instead I start postgres with pg_ctl, load some sql files containing my table creations, and stop the server with pg_ctl.
My shell script looks like this:
#!/bin/bash
echo "******CREATING DOCKER DATABASE******"
echo "starting postgres"
gosu postgres pg_ctl -w start
echo "bootstrapping the postgres db"
gosu postgres psql -h localhost -p 5432 -U postgres -a -f /db/bootstrap.sql
echo "initializing tables"
gosu postgres psql -h localhost -p 5432 -U postgres -d orpheus -a -f /db/setup.sql
echo "stopping postgres"
gosu postgres pg_ctl stop
echo "stopped postgres"
echo ""
echo "******DOCKER DATABASE CREATED******"