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

标签 python docker tkinter socat xquartz

这是我的步骤..

安装 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/

相关文章:

python - 值错误 : empty vocabulary; perhaps the documents only contain stop words

java - Docker容器HttpUrlConnection超时异常

networking - Docker-Rhel 7上的覆盖网络

Python Tkinter 窗口和小部件尺寸测量

python - EnumDisplayDevices 提供两个显示器,即使我有一个

python - group by pandas 删除重复项

Docker启动sonarqube :7. 5-community fails with es log permission

Python 文本小部件仅在窗口中打开

python - 如何写入我使用 filedialog.asksaveasfile 选择的文件?

python - Django 模型中的对象总数