为什么我不能运行X11应用程序? [英] why can i not run a X11 application?

查看:407
本文介绍了为什么我不能运行X11应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,正如标题所示,我是 docker 新手。
我下载并安装了 archlinux / base 容器,到目前为止,该容器似乎运行良好。我已经设置了一些东西,并安装了一些软件包(包括 xeyes ),现在我想启动 xeyes 。为此,我通过运行 docker ps 找出了容器ID,然后在我的exec命令中使用了该ID,现在看起来像这样:

So, as the title states, I'm a docker newbie. I downloaded and installed the archlinux/base container which seems to work great so far. I've setup a few things, and installed some packages (including xeyes) and I now would like to launch xeyes. For that I found out the CONTAINER ID by running docker ps and then used that ID in my exec command which looks now like:

$ docker exec -it -e DISPLAY=$DISPLAY 4cae1ff56eb1 xeyes
Error: Can't open display: :0

为什么它仍然不起作用?此外,如何在不丢失其配置状态的情况下停止正在运行的实例?以前,我退出了该容器,重新启动它后,所有配置和软件安装都消失了。那是不希望的。如何正确处理呢?

Why does it still not work though? Also, how can I stop my running instance without losing its configured state? Previously I have exited the container and all my configuration and software installations were gone when I restarted it. That was not desired. How do I handle this correctly?

推荐答案

关于X显示器,您需要共享 xserver 套接字(注释 docker 无法绑定装入并在 exec 期间设置 $ DISPLAY (例如 Dockerfile ):

Concerning the X Display you need to share the xserver socket (note: docker can't bind mount a volume during an exec) and set the $DISPLAY (example Dockerfile):

FROM archlinux/base

RUN pacman -Syyu --noconfirm xorg-xeyes

ENTRYPOINT ["xeyes"]

构建 docker 图片: docker build --rm --network host -t so:57733715。

运行 docker 容器: docker运行--rm -it -v /tmp/.X11-unix:/tmp/.X11- unix -e DISPLAY = unix $ DISPLAY这样:57733715

注意:如果未指定协议错误,您可以使用 xhost + 禁用主机检查,但是会出现警告( man xhost 获取更多信息)。

Note: in case of No protocol specified errors you could disable host checking with xhost + but there is a warning to that (man xhost for additional information).

这篇关于为什么我不能运行X11应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆