Description
Hi.
We are using the official postgres docker image in our CI system and we've found that gosu is not working since the last changes (because we haven't change anything from our part).
What we do is just build our docker image based on the latest
version of the official docker image for Postgres just adding few SQL scripts inside /docker-entrypoint-initdb.d
. What we have found is that our image is build correctly but the image never cames up because it returns an error. This is exactly what we can see after trying to starting the container:
...
waiting for server to start....LOG: database system was shut down at 2017-03-22 15:06:56 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
done
server started
ALTER ROLE
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/01-init-db.sh
error: failed switching to "postgres": operation not permitted
Here you can see part of the Dockerfile we are using:
FROM postgres:latest
ENV DB_USER xxx
ENV DB_PASSWORD xxx
ENV DB_NAME xxx
ENV DB_ENCODING UTF-8
ADD init/*.sh /docker-entrypoint-initdb.d/
RUN chmod +x /docker-entrypoint-initdb.d/*.sh
And in this case this is the shell script (01-init-db.sh
) that we would like to run that is stored in our `/init' folder:
#!/bin/bash
{ gosu postgres psql --user postgres <<-EOSQL
CREATE USER "$DB_USER" WITH PASSWORD '$DB_PASSWORD';
CREATE DATABASE "$DB_NAME" WITH OWNER="$DB_USER" TEMPLATE=template0 ENCODING='$DB_ENCODING';
EOSQL
}
We have found recently some changes on the docker-entrypoint.sh
, could be possible that those changes made gosu
not work?
Best,