简体   繁体   中英

How to use host DISPLAY within docker

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

Though this question is very old and many people may have similar issue\/question.

But none worked. Then I used host pid<\/strong> in docker and it worked.

$ xhost +local:
$ docker run --pid=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM