Xquartz:可以打开显示Mac OS

发布于 2025-02-06 13:26:58 字数 1213 浏览 4 评论 0 原文

在尝试关注这些指令使用Xquartz在Mac(10.15.5)上从Docker容器中运行的简单Xeyes应用程序,这就是我得到的:

$ DOCKER RUN -IT -IT -E DISPLAS =“ $ {ip}:0” -V / tmp/.x11-unix:/tmp/.x11-unix so_xeyes

/work#xeyes 错误:无法打开显示:192.168.1.9:0


这是复制的步骤:

$ brew install -cask xquartz

dockerfile:

# Base Image
FROM alpine:latest

RUN apk update && \
    apk add --no-cache xeyes

# Set a working directory
WORKDIR /work

# Start a shell by default
CMD ["ash"]

构建图像

用: $ docker build -docker build -t so_xeyes 。

并使用以下方式运行Docker Container/Xeyes:

# Set your Mac IP address
IP=$(/usr/sbin/ipconfig getifaddr en0)
echo $IP
192.168.1.9

# Allow connections from Mac to XQuartz
/opt/X11/bin/xhost + "$IP"
192.168.1.9 being added to access control list

# Run container
docker run -it -e DISPLAY="${IP}:0" -v /tmp/.X11-unix:/tmp/.X11-unix so_xeyes

在容器内,键入: Xeyes

但是,我会收到以下错误:错误:无法打开显示:192.168.1.9:0

有人知道我如何解决此问题或进一步研究?

While trying to follow these SO instructions for getting a simple Xeyes application running from within a Docker container on a Mac (10.15.5) using XQuartz, this is what I get:

$ docker run -it -e DISPLAY="${IP}:0" -v /tmp/.X11-unix:/tmp/.X11-unix so_xeyes

/work # xeyes
Error: Can't open display: 192.168.1.9:0


Here are the steps to reproduce:

$ brew install --cask xquartz

Dockerfile:

# Base Image
FROM alpine:latest

RUN apk update && \
    apk add --no-cache xeyes

# Set a working directory
WORKDIR /work

# Start a shell by default
CMD ["ash"]

Build image with:

$ docker build -t so_xeyes .

And run the Docker Container/xeyes with this:

# Set your Mac IP address
IP=$(/usr/sbin/ipconfig getifaddr en0)
echo $IP
192.168.1.9

# Allow connections from Mac to XQuartz
/opt/X11/bin/xhost + "$IP"
192.168.1.9 being added to access control list

# Run container
docker run -it -e DISPLAY="${IP}:0" -v /tmp/.X11-unix:/tmp/.X11-unix so_xeyes

When inside the container, type:
xeyes

BUT, I get the following error: Error: Can't open display: 192.168.1.9:0

Does anyone have an idea how I can resolve this or to investigate further?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Spring初心 2025-02-13 13:27:00

@MarkSetchell给了我一个暗示,建议我需要修改Xquartz 首选项> Security ...

但是,即使选择“允许网络客户端的连接”,它仍然无法正常工作。

然后我找到了一个要点,在这里给了我更多信息,因为有人评论说,他们进行了更改后,他们需要重新启动Mac(再次):https://gist.github.com/cschiewek/246a244ba23da8b9f0e7b11a68bf3285

So, after I made the change AND rebooted my Mac, it worked!

感谢您指导我获得最终答案!

另请注意:您不需要汇编.x11目录才能工作:

docker run -e it -e display =“ $ {ip}:0” so_xeyes

@MarkSetchell gave me a hint with suggesting I needed to modify the XQuartz Preferences > Security...

But, even after selecting "Allow connections from network clients", it still didn't work.

enter image description here

Then I found a Gist that gave me a little more information here because someone commented that after they made the change, they needed to reboot their Mac (again): https://gist.github.com/cschiewek/246a244ba23da8b9f0e7b11a68bf3285

So, after I made the change AND rebooted my Mac, it worked!

Thanks for guiding me to the final answer!

ALSO NOTE: You do NOT need to volume mount the .X11 directory for this to work:

docker run -it -e DISPLAY="${IP}:0" so_xeyes

绾颜 2025-02-13 13:27:00

默认情况下,X11不会通过TCP/IP聆听。您可以在设置中启用,但我认为这里不需要。 Docker应该能够将流量路由到Unix域插座设置bunaindd for Display(例如:/private/tmp/com.apple.launchd.jtifzplv7a/org.xquartz:0)。

如果这样做不起作用,您应该与Docker联系以增加对此的支持,因为它更喜欢将TCP用于X11流量。

By default, X11 does not listen over TCP/IP. You can enable that if you want in Settings, but I don't think it's necessary here. Docker should be able to route traffic to the unix domain socket setup by launchd for DISPLAY (eg: /private/tmp/com.apple.launchd.jTIfZplv7A/org.xquartz:0).

If that doesn't work, you should reach out to Docker to add support for that as it's much preferred to using TCP for X11 traffic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文