Self cross-posting from: lemmy.zip/post/70909658
Intention to have slightly better visibility from the self-hosted crowd and I’m interested in more general feedback on this too.
Hey everyone! I’m trying to find a solution to a really confusing problem…
I have the following simple nginx docker compose configuration on my Fedora home server that I can run without issue on my uid
1000user, lets call this user “userA”.services: nginx: container_name: nginx-alt image: docker.io/library/nginx restart: unless-stopped ports: - 8181:80This exposes internal port 80 as 8181 and can be accessed in a lan in the expected matter.
However, for security reasons, I want to actually host this service eventually on a completely different user with less permissions. Let’s call this user “userB” who has a very limited scope of the file system. This is to prevent potential escaping of the rootless container causing major file system havoc (i.e. reduce the scope of the user to a very limited network of containers.)
The problem is really simple: For some reason, when userB runs this service (uid
1001), the nginx service suddenly complains about privileges. As a result, I get a “Forbidden 403” error when hosting. Turning off selinux has no affect (sosetenforce 0does nothing, meaning I can rule out secure linux interruption.)The errors look like the following:
nginx-alt | 2026/09/04 20:03:34 [error] 25#25: *1 "/usr/share/nginx/html/index.html" is forbidden (13: Permission denied), client: xx.xx.x.x, server: localhost, request: "GET / HTTP/1.1", host: "xxx.xxx.xxx.xxx:8181" nginx-alt | 10.89.0.2 - - [04/Sep/2026:20:03:34 +0000] "GET / HTTP/1.1" 403 153 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:155.0) Gecko/20100101 Firefox/155.0" "-"For what it’s worth, both users should be relatively vanilla and all ports are appropriately exported. There shouldn’t be anything, for example, that is making userA run as “privileged” over the other users and podman should be running rootless in both containers.
I did see a note on the nginx image about running in rootless that I might try, but it doesn’t solve my bigger issue here which is the lack of consistency between the two users. Additionally,
userns_mode: keep-idsonly caused the container to fail to boot for other reason entirely.There must be something fundamentally wrong with my configuration of my system. Has anyone had any experience running two podman containers on two different users simultaneously that can provide feedback?
Obviously, I’m not trying to run just an nginx server, but I found this to be the easiest configuration to reproduce.
chameleon@fedia.io
glizzyguzzler@piefed.blahaj.zone 2 weeks ago
The best way to run Podman is root with UserNS to dole out UID/GID protection. Running Podman as root allows you to share networks between containers while having the containers run under different users. If you go rootless, you’d need to run under one user to share the user’s network space with all the containers you want.
As for your issue, I can’t really divine what the problem is from the errors. I avoid nginx because it’s coded to not play well with user abstraction and changing the user with the files it wants to write to etc. Gotta write into a ton of random folders! So not sure exactly what is up. But with Podman root it is easy to run as root
0internally and make nginx think it has all the control it could ever want.Try this setup (it is in Podman Quadlet format, apologies I don’t know the compose versions). It runs the container as root
0internally, externally it runs as some random UID/GID - secure! It uses Volumeidmapto map the internal root0user to1001for write access to the Volume.Note that in Debian 13 symlinks are broken and won’t work with
idmap, just point to the original source. If you need symlinks, I have an alternate UserNS that maps internal user root0to external user1001directly. You’d drop theidmapin Volume then and use that. You lose some extra security - now the container is running as external user1001instead of some random UID/GID - but that’s a pretty minor hit as long as your external user doesn’t have access to tons of things.Root Podman and UserNS=auto needs a
containersuser to pull uid/gid from.The documentation for Podman is critically lacking in the “hobbyist” space. Hope this helps.
Note that sudo echo does not work as non root because the shell redirection is attempted before the command runs. You want
echo foo | sudo tee -a /barinsteadglizzyguzzler@piefed.blahaj.zone 2 weeks ago
So the sudo echo does echo as sudo but doesn’t carry over? Makes sense damn I hate bash! Any way to keep the >>? Or do you need to tee? Cause the >> is pretty cool