Sharing X11 socket as unprivileged user fails with "Can't open display" #13040
-
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line) /kind bug Description On a Debian Bullseye host, sharing the Steps to reproduce the issue: Given Dockerfile like:
Build and run the image:
So this fails. However, running as root inside the container succeeds:
The app I am switching from docker to podman is Tor Browser, which doesn't like running as root. I'm showing the issue with xclock above instead for a simpler repro case. So with podman running as my non-privileged user on my host, it can access the X11 socket as root inside the container. Interestingly, if I execute the File ownership of
Inside the container created with
The non-privileged user in the container ends up with uid:gid Describe the results you received: Error message when non-root user runs X11 apps. Describe the results you expected: No error. Output of
Output of
Package info (e.g. output of
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md) Checked the guide, did not try building from latest commit yet. #5226 seems related in terms of symptoms, but the suggested workarounds there ( Additional environment details (AWS, VirtualBox, physical, etc.): Physical host |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
I vaguely remember looking into something like this in the past, but I can't remember what the missing piece was. You can:
... or just use Flatpak? |
Beta Was this translation helpful? Give feedback.
-
My guess is something to do with user namespace or with other namespaces. |
Beta Was this translation helpful? Give feedback.
-
This is a discussion though not an issue. |
Beta Was this translation helpful? Give feedback.
-
I think you need to map the host user to the user in the container (UID=1000, GID=1000) with --uidmap. Using --gidmap does not seem to be necessary in this case, but I add it to make the solution below a bit more general.
The same commands on a single line:
I tried it out by logging in to a test user on my laptop with
Starting xclock with the commands above worked. A window was shown with an analog clock. My laptop is running Fedora 35. |
Beta Was this translation helpful? Give feedback.
I think you need to map the host user to the user in the container (UID=1000, GID=1000) with --uidmap.
Using --gidmap does not seem to be necessary in this case, but I add it to make the solution below a bit more general.