18.7: /var/lib/postgresql is 755 instead of 1777, breaks running as an arbitrary user

Open Beginner friendly
#1,427 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, postgresql
Domain
databases

Research direction

Start by reading the Dockerfile section that sets /var/lib/postgresql to mode 1777 and the issue’s description of postgresql-common’s tmpfiles configuration and post-install step. Build and run the Debian-based postgres:18.7 image as an arbitrary UID, checking the directory mode and whether startup succeeds. Done means the directory remains usable by an arbitrary UID and the container starts successfully.

Written by the indexing model from the issue text.

Description

We noticed this when our CI broke after postgres:18 moved to 18.7. We run the image as a service container on OpenShift, which starts it with an arbitrary UID, and it now exits at once:

$ docker run --rm --user 1000770000:0 -e POSTGRES_PASSWORD=x postgres:18.7
mkdir: cannot create directory ‘/var/lib/postgresql/18’: Permission denied

/var/lib/postgresql was 1777 and is now 755:

$ docker run --rm --entrypoint stat postgres:18.6 -c %a /var/lib/postgresql
1777
$ docker run --rm --entrypoint stat postgres:18.7 -c %a /var/lib/postgresql
755

It looks like postgresql-common 294 resets it: it now ships /usr/lib/tmpfiles.d/postgresql-common.conf with d /var/lib/postgresql 0755 postgres postgres, and its postinst runs systemd-tmpfiles --create, after the Dockerfile's install --mode 1777. The alpine variant still has 1777.

Dominant language
Shell
Stars
2.5k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker-library/postgres

All issues in docker-library/postgres

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.