Postgresql – How to relax file permissions conditions on postgres database folder

dockerpostgresqlwindows 10

Postgresql service refuses to start if the data folder (PGDATA) doesn't belong exclusively to the postgres user (i.e. permissions = 700).

Is there any way to disable or circumvent that condition? Ideally I would like postgresql to start even if the permissions on that folder is set to 777.

Explanations:

I have built a Docker image with a running instance of Postgresql. The requirements are:

  • a) the container should be able to run on Windows Home edition (which
    means Docker for Windows is not an option and we have to use
    docker-machine and VirtualBox)
  • b) the user should use Kitematic to
    download and run the Image, without any need to go to the command
    line or do any post-install configuration (i.e. it should work out of
    the box). This means that I only have control over what happens
    within the container running Psql; I can't change the VM or Windows
    configs.
  • c) the database must be stored on a data volume mounted on
    the file system of the host OS (because I want the container to be
    disposable and upgradable)

a) and b) works perfectly well. But as soon as the user enables the Data Volume in Kitematic (condition c) ) Postgres refuses to start because the owner of the DB folder is reset to 1000:staff which are the default user and group in boot2docker Virtal Machine. There is no way to programmatically change the owner or permissions inside the VirtualMachine due to the way VBox shares the folder with Windows (via a vboxfs mount).

So basically within the container I'm stuck with a PGDATA folder with full access to everyone (i.e. 777, which is not a really an issue in itself since the data is not sensitive and not exposed to other machines).

Best Answer