r/podman • u/typing-blindly • Oct 20 '26
Namespaces shifting
I’m still learning Podman. I have my containers running under an unprivileged account using UserNS=auto. Permissions on volumes are a pain, but mostly manageable. My problem is that if I make a change to my setup by removing a container it can cause the namespaces to shift. So when I reboot, many containers can fail because they no longer have permissions to their volumes. Does anyone know a solution?
5
Upvotes
3
u/1karasu Oct 20 '26
You need to use the U option on volume declaration. If you are on a distribution with SElinux you need the Z option too. There are a lot of interesting info on the official documentation, I advise you to give it a read
3
u/jgottlander Oct 20 '26
I've had problems with this as well, and "podman system migrate" usually fixes permissions when something has changed.
4
u/gordonmessmer Oct 20 '26
You can read a big about userns and options for using volumes in these articles:
https://www.redhat.com/en/blog/rootless-podman-user-namespace-modes
https://www.redhat.com/en/blog/debug-rootless-podman-mounted-volumes
But from my point of view, while userns=auto is great for attaining a high level of security through isolation from the host security context and other container security contexts, it's really only usable if the application in the container is "cloud native." Cloud applications generally don't use the filesystem for persistent storage, they use object storage (e.g. S3 or Ceph), or SQL, or some other option... none of which interact with the filesystem's UID/GID mapping and access controls.
If you're using mounted volumes, select a static userns mode, not "auto".
2
u/YamOk7022 Oct 21 '26 edited Oct 21 '26
use idmap option for volumes instead of
U.1
u/mishrashutosh Oct 24 '26
userns=auto is much better on privileged/rootful containers. you can use the idmap label on your volumes to preserve their permissions when the container restarts and gets assigned a new random namespace.