USER envvar no longer respected
Using the latest image (bbpsrhag7rw7a4b6nrcy5hg on Ubuntu 14.04.1/Docker 1.2.0), providing the USER environment variable seems to have no effect, and it will default to 'super'.
$ docker run -d -p 127.0.0.1:5432:5432 \
-e USER="mydbuser" -e DB="mydb" -e PASS="mypass" \
paintedfox/postgresql
b46c52755....
$ docker logs b46
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 16
POSTGRES_USER=super
POSTGRES_PASS=mypass
POSTGRES_DATA_DIR=/data
POSTGRES_DB=mydb
Initializing PostgreSQL at /data
Starting PostgreSQL...
Creating the superuser: super
2014-09-17 04:16:38 UTC LOG: database system was shut down at 2014-09-17 02:30:14 UTC
2014-09-17 04:16:38 UTC LOG: database system is ready to accept connections
2014-09-17 04:16:38 UTC LOG: autovacuum launcher started
NOTICE: role "super" does not exist, skipping
Creating database: mydb
It seems like USER is a reserved environment variable in phusion/baseimage.
See https://github.com/phusion/baseimage-docker/blob/master/image/bin/my_init#L81 and https://github.com/phusion/baseimage-docker/commit/18a7fe26ec13235db66e37e9c0f3ca24bc0116ed
I had the same problem, and modified the first line in first_run.sh to: USER=${DB_USER:-super}, and then set the username through the DB_USER environment variable instead.
YES, USER has been ignored. just run the container, and check the /sbin/my_init, on line 81: if name in ['HOME', 'USER', 'GROUP', 'UID', 'GID', 'SHELL']: continue
so, just change the variables, and rebuild.
+1 Had to do what @heyman said, clone this repo, fix first_run.sh and build the docker image
I've fixed this issue in my fork https://github.com/lanrat/docker-postgresql See https://github.com/lanrat/docker-postgresql/commit/4a20359bc9cab9c53720dfa65afd91ba3a39515d