Closed ackava closed 7 months ago
It might be simpler to user a sidecar container to achieve this.
@LaurentGoderre Another container, additional configuration, additional code, additional dependency, just to avoid a single folder which can have write access same as pguser?
In that case you can use the initialization script to run those changes in a bash script inside /docker-entrypoint-initdb.d
@LaurentGoderre I have updated my original post, it fails with error operation not permitted
.
The entrypoint script only sets up permissions on a minimum set of directories and we are unlikely to add more. We'd rather not add yet more environment variables.
Any extra directories you need should be provided with the correct permissions for the postgres
user to access (or the user that you are running the contianer as). Unfortunately the initdb.d scripts are run as the postgres
user (the drop down from root
occurs earlier), so the few options are:
bash -c 'set -e; mkdir -p /custom/path; chown ...; exec docker-entrypoint.sh postgres
FROM postgres:verison
RUN set-e; mkdir -p /custom/path; chown ...
fsgroup
in k8s)
I am aware of POSTGRES_INITDB_WALDIR and I am using it, but what I want to achieve is, I want to archive the logs periodically to different docker volume which is synced to S3 or any other cloud storage. Currently, I am forced to archive logs in the subfolder of WALDIR because I cannot copy logs to volume outside of PGDATA or WALDIR.
I also tried putting
chmod 777 $POSTGRES_ARCHIVE_DIR
in/docker-entrypoint-initdb.d/setup.sh
but it results in erroroperation not permitted
I have created following patch, https://github.com/docker-library/postgres/compare/master...ackava:postgres:master
However, I am not sure if this is correct way to do it, that's why I haven't submitted the pull request.
In which, we can manually specify the variable
POSTGRES_ARCHIVE_DIR
, which will enable archiving logs to specified folder and specific configuration turned on. Also give access rights to PGUSER, currently I have no way to give access rights to a different volume.