从这个文章中,它声明windows 11本机支持在wsl上运行X11和wayland应用程序。
我试图通过一个docker容器进行同样的操作,设置环境变量DISPLAY="host.docker.internal:0.0"
,并运行gui应用程序(如gedit
)。但是我得到了一个错误:
Unable to init server: Could not connect: Connection refused
Gtk-WARNING **: 17:05:50.416: cannot open display: host.docker.internal:0.0
发布于 2022-09-29 20:25:48
当我尝试和你一样的事情时,我偶然地发现了你的问题,并且用这篇关于微软的博文来帮助它工作。我使用基于Ubuntu的最小Dockerfile并安装gedit
FROM ubuntu:22.04
RUN apt update -y && apt install -y gedit
CMD ["gedit"]
按照通常的方式创建图像,例如docker build . -t guitest:1.0
在WSL命令行上,按如下方式启动:
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix \
-v /mnt/wslg:/mnt/wslg \
-e DISPLAY \
-e WAYLAND_DISPLAY \
-e XDG_RUNTIME_DIR \
-e PULSE_SERVER \
guitest:1.0
我希望这对你也有很好的利用。
https://stackoverflow.com/questions/73092750
复制相似问题