Sharing the Xserver with docker container
Tong Sun
suntong001 at gmail.com
Mon Jan 25 03:42:01 UTC 2021
On Sun, Jan 24, 2021 at 10:31 PM Ryan Schmidt <ryandesign at macports.org> wrote:
>
> On Jan 24, 2021, at 21:26, Tong Sun wrote:
>
> > On Sun, Jan 24, 2021 at 10:24 PM Ryan Schmidt wrote:
> >>
> >> On Jan 24, 2021, at 21:15, Tong Sun wrote:
> >>
> >>> On Sun, Jan 24, 2021 at 9:30 PM Ryan Schmidt wrote:
> >>>
> >>>> On Jan 24, 2021, at 18:01, Tong Sun wrote:
> >>>>
> >>>>> For any Xserver in host, I normally just do the following in the
> >>>>> docker container
> >>>>>
> >>>>> export DISPLAY=':0'
> >>>>> xterm &
> >>>>>
> >>>>> and I'll be all set.
> >>>>>
> >>>>> However, I found that it is not the case for Xserver from macport, as
> >>>>> I see my DISPLAY in my host is
> >>>>>
> >>>>> DISPLAY=/private/tmp/com.apple.launchd.DiHpGrxgFr/org.macports:0
> >>>>>
> >>>>> How can I share that with my docker container?
> >>>>
> >>>> I'm not sure. Did you try first starting the X server on your Mac, and then doing what you did before in Docker?
> >>>
> >>> I'm very new to both Mac and macport. how to start the X server on Mac?
> >>>
> >>> I used macport to install xorg-server, then tried to start xterm.
> >>> xterm started fine, meaning my xorg-server started fine,
> >>> then I checked the DISPLAY in xterm, which is the above value.
> >>
> >> Starting any X11 program, such as xterm, will start the X11 server. Or you can manually launch /Applications/MacPorts/X11.app.
> >>
> >> Now that X11.app is running on macOS, what happens if you try to use X11 from your Docker container, with DISPLAY set to ":0"?
> >
> > Error: Can't open display: :0
>
>
> 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"
More information about the macports-users
mailing list