Sharing the Xserver with docker container

Tong Sun suntong001 at gmail.com
Mon Jan 25 04:06:29 UTC 2021


On Sun, Jan 24, 2021 at 10:45 PM Ryan Schmidt <ryandesign at macports.org> wrote:
>
>
>
> On Jan 24, 2021, at 21:42, Tong Sun wrote:
>
> > On Sun, Jan 24, 2021 at 10:31 PM Ryan Schmidt wrote:
> >
> >> I found this article about how to do this. Maybe it will help?
> >>
> >> https://medium.com/@mreichelt/how-to-show-x11-windows-within-docker-on-mac-50759f4b65cb
> >>
> >> Where it says "install XQuartz", don't, since you already have the MacPorts X11.app which is equivalent to but newer than XQuartz.
> >>
> >> It sounds like the key may be to set "Allow connections from network clients" in X11.app's Preferences window, close and reopen X11.app, and run "xhost + 127.0.0.1" and "export DISPLAY=host.docker.internal:0" in the Docker image.
> >
> > Hmm... I've looked everywhere but cannot find this "Allow connections
> > from network clients" in X11.app's Preferences window. Where can I
> > find it?
> >
> > Without such step, I'm getting
> >
> > $ xhost + 127.0.0.1
> > xhost:  unable to open display "127.0.0.1:0"
>
> Open X11.app. Choose Preferences from the X11 menu. Select the Security tab.

Ah, got it working. Thanks a lot!!

Just that there is 10 extra second delay, which I have no idea where
it is coming from --

$ time xclip -o -selection clipboard
Last login: Sun Jan 24 17:05:13 on console

real 0m10.057s
user 0m0.002s
sys 0m0.004s

Subsequent requests are served very fast:

$ time xclip -o -selection clipboard
Last login: Sun Jan 24 17:05:13 on console

real 0m0.014s
user 0m0.003s
sys 0m0.002s

until the clipboard content is changed, when there will be another
extra 10s delay.

Neither  macport's xorg-server nor docker should cause such delay. Weird.


More information about the macports-users mailing list