gpt4 book ai didi

python - 尝试在 Docker 中将 TkInter 与 Socat 一起使用 - Mac

转载 作者:太空宇宙 更新时间:2023-11-03 14:53:10 25 4
gpt4 key购买 nike

这是我的步骤..

安装 Socat 和 XQuartz

brew install socat
brew cask install xquartz

打开 XQuartz 设置 Socat Listener

open -a XQuartz
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

使用 DISPLAY 环境变量运行 Docker 容器

docker run -e DISPLAY=192.168.0.13:0 tkinter sh

这是我收到的错误。

//容器

_tkinter.TclError: couldn't connect to display "192.168.0.13:0"

//索卡特

socat[37688] E connect(8, LEN=2 AF=1 "", 2): Invalid argument

任何其他 IP 地址都会给我带来类似的错误,但不会显示在 Socat 中,因此我可以假设我的 IP 是正确的。

如有任何建议,我们将不胜感激。

最佳答案

您是否尝试在 docker 中运行 GUI 应用程序?你见过this方法?

打开 Xquartz 后,您必须允许来自网络客户端的连接。我知道在 Linux 上您必须共享 .x11 卷并启用 xhost,看起来在 Mac 上您也必须执行相同的操作:

ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + $ip
docker run -d --name displayContainer -e DISPLAY=$ip:0 -v /tmp/.X11-unix:/tmp/.X11-unix <yourRepo>/<yourImage>

关于python - 尝试在 Docker 中将 TkInter 与 Socat 一起使用 - Mac,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45777939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com