1

podman says Error: Can't open display: localhost:10.0 when I try to run xclock in a container with the command podman run -ti -e DISPLAY --rm -v ~/.Xauthority:/root/.Xauthority:Z localhost/xclockimage on a Fedora 29 computer.

Longer story

On my laptop running Ubuntu 18.10 I first logged in to another physical machine over ssh.

[erik@laptop ~]$ ssh -X testuser@server.example.com

The server is running Fedora 29 and my user testuser does not have sudo permissions. I then built a container image for the xclock application with the build tool buildah and a Dockerfile.

[testuser@server ~]$ cd ~/test
[testuser@server test]$ cat Dockerfile
FROM fedora

RUN yum -y update
RUN yum -y install xorg-x11-apps && yum clean all

CMD [ "/usr/bin/xclock" ]
[testuser@server test]$ buildah bud -t xclockimage .

but when I try to run it, podman fails with the error message Error: Can't open display: localhost:10.0

[testuser@server ~]$ podman run -ti -e DISPLAY --rm  -v 
~/.Xauthority:/root/.Xauthority:Z  localhost/xclockimage  
Error: Can't open display: localhost:10.0
[testuser@server ~]$ 

Some more information

[testuser@server ~]$ cat /etc/fedora-release 
Fedora release 29 (Twenty Nine)
[testuser@server ~]$ podman --version
podman version 1.0.0
[testuser@server ~]$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      31
[testuser@server ~]$ 

(No changes have been made to the SELINUX settings of the server since it was installed)

How do I run an X11 graphical (GUI) application with podman?

1

Add --net=host to the command line

[testuser@server ~]$ podman run -ti -e DISPLAY --rm -v 
~/.Xauthority:/root/.Xauthority:Z --net=host localhost/xclockimage

After this change it started to work.

0

When using ubuntu:20.04

I found that -u 0 will solve the problem for podman, and -u $UID for docker.

$podman run -it -u 0 -e DISPLAY="$DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:rw podman-image xclock

$docker run -it -u $UID -e DISPLAY="$DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:rw docker-image xclock

On the docker file install x11-apps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.