Reputation: 22994
How to use host DISPLAY
within docker?
I setup DISPLAY
within my docker instance and want to use it for my xapps. But this is what I'm getting:
me@178887a67067:/$ env | grep DISPLAY
DISPLAY=192.168.0.102:2
me@178887a67067:/$ xterm &
[1] 11
me@178887a67067:/$ xterm: Xt error: Can't open display: 192.168.0.102:2
[1]+ Exit 1 xterm
How to allow xapps within docker to connect and use my host DISPLAY
without using host-network (--network host
)? Thanks.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
[Amend]
I know it must sounds like an FAQ, but I've tried all the methods from the following sites, but none is working for me:
Using the simplest solution from https://iamhow.com/How_To/Docker_How_To.html#1484268 as an example:
$ xhost +local:
non-network local connections being added to access control list
$ docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro image
# env | grep DISPLAY
DISPLAY=192.168.0.102:2
# xterm &
Warning: This program is an suid-root program or is being run by the root user.
...
xterm: Xt error: Can't open display: %s
[1]+ Exit 1 xterm
Upvotes: 5
Views: 5646
Reputation: 674
Though this question is very old and many people may have similar issue/question.
I searched google and tried all the methods from different website. But none worked. Then I used host pid in docker and it worked.
Try using host pid in the docker.
$ xhost +local:
$ docker run --pid=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro image
Upvotes: 7