pgAdmin container cannot write to /var/lib/pgadmin
Permission denied: '/var/lib/pgadmin/sessions'Short answer
The pgAdmin image runs as user 5050 in group 0, not as root. A host folder mounted on /var/lib/pgadmin must be writable by that user. Change the folder owner to 5050:0, or on SELinux hosts and rootless Podman add the volume options the pgAdmin docs give.
Fix it fast
1Find out which cause you have
Look at who owns the host folder you mounted. The pgAdmin docs say the process runs as UID 5050, so anything else owning the folder is the first suspect.
ls -ldn ./pgadmin-data2Match what you see, then jump to its fix
- 1
ls -ldn shows root (0) or your own user id instead of 5050The host folder is owned by someone other than 5050Fix - 2
Ownership is correct and the error remains on Fedora, RHEL, Rocky or AlmaSELinux blocks the bind mountFix - 3
You run the image with rootless Podman and chown 5050 made no differenceRootless Podman maps user IDs differentlyFix
- 1
What does the error look like?
Permission denied: '/var/lib/pgadmin/sessions'
Cause 1 of 3
The host folder is owned by someone other than 5050
1Check
The docs state that pgAdmin runs as the pgadmin user (UID 5050) in group 0, and that mounted files must be readable and the session directory writable by that user.
docker exec pgadmin id2Fix
Give the folder to that user and group, then start the container again.
sudo chown -R 5050:0 ./pgadmin-data
docker compose up -d3Verify
The container stays up and the log shows no permission error.
docker logs --tail 20 pgadminConfirmed by pgadmin.org
Cause 2 of 3
SELinux blocks the bind mount
1Check
The pgAdmin docs say chown does not change SELinux labels. On a host with SELinux enforcing, the mount needs a label option.
getenforce2Fix
Add Z (private label) or z (shared label) to the volume. The docs show the form with Z.
volumes:
- ./pgadmin-data:/var/lib/pgadmin:Z3Verify
Recreate the container and read the log.
docker compose up -d --force-recreate
docker logs --tail 20 pgadminConfirmed by pgadmin.org
Cause 3 of 3
Rootless Podman maps user IDs differently
1Check
In a rootless container, container user IDs map to a range of subordinate IDs on the host, so the host owner you set is not the one the container sees.
podman unshare ls -ldn ./pgadmin-data2Fix
Add the U option so Podman changes ownership to match the container user. On SELinux hosts combine it with Z, as the docs do.
podman run -v ./pgadmin-data:/var/lib/pgadmin:Z,U docker.io/dpage/pgadmin43Verify
The container starts and pgAdmin answers on its port.
podman logs --tail 20 pgadminConfirmed by pgadmin.org
How do I stop it coming back?
- Prefer a named volume for /var/lib/pgadmin when you do not need the files on the host.
- Set ownership of any bind-mount folder before the first start.
- Keep the image tag pinned and read the container notes when you upgrade.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A dev container port does not open in the browser when Docker runs on a remote host
If your application only accepts calls from localhost, it will reject connections from published ports
Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.
3 causes, each with a fix