Rootless Podman maps your UID to root inside the container and all other UIDs to a range from /etc/subuid. A folder that belongs to you therefore belongs to root inside the container – a service running as UID 70 may not write there.
Symptom
podman ps -a --filter name=r15-db --format '{{.Names}}\t{{.Status}}'
r15-db Exited (1) 4 seconds ago
Postgres should run as UID 70 with its data in the project folder under pgdata/. The container is dead after one second.
Diagnosis
Log, mount and the owner from both views.
podman logs r15-db 2>&1 | tail -1 grep -- '-v ' start-db.sh ls -ldn pgdata podman unshare ls -ldn pgdata mkdir: can't create directory '/var/lib/postgresql/18/': Permission denied -v ./pgdata:/var/lib/postgresql docker.io/library/postgres:18.6-alpine drwxr-xr-x 2 1000 1000 4096 Oct 30 23:13 pgdata drwxr-xr-x 2 0 0 4096 Oct 30 23:13 pgdata
Causes
1000 → 0Your UID is root inside the container
On the host pgdata belongs to UID 1000, in the user namespace that is UID 0. Postgres runs as UID 70 and may not write.
podman unshareTwo views of the same files
podman unshare shows the view from inside the user namespace. Without it everything looks right, because the folder belongs to “you”.
Fix
podman rm r15-db >/dev/null sed -i 's#/var/lib/postgresql docker#/var/lib/postgresql:U docker#' start-db.sh ls -ldn pgdata podman unshare ls -ldn pgdata drwxr-xr-x 3 100069 100069 4096 Oct 30 23:13 pgdata drwxr-xr-x 3 70 70 4096 Oct 30 23:13 pgdata
Don't: Open the folder with chmod 777 – then every process on the host may read and write the database files.
Container tools hands-on, Day 16: repair ten broken container setups with Podman, Quadlet, crane, skopeo and cosign.
Go to day 16 →
FAQ
How do I delete the folder afterwards?
It now belongs to UID 100069 on the host – delete it with podman unshare rm -rf pgdata.
Where does 100069 come from?
From /etc/subuid – UID 70 in the container corresponds to the start of the range plus 69 on the host.