简体   繁体   English

为什么我不能运行X11应用程序?

[英]why can i not run a X11 application?

So, as the title states, I'm a docker newbie. 因此,正如标题所述,我是docker新手。 I downloaded and installed the archlinux/base container which seems to work great so far. 我下载并安装了archlinux/base容器,到目前为止,该容器似乎运行良好。 I've setup a few things, and installed some packages (including xeyes ) and I now would like to launch xeyes . 我已经设置了一些东西,并安装了一些软件包(包括xeyes ),现在我想启动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 ps找出了容器ID,然后在我的exec命令中使用了该ID,现在看起来像:

$ 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? 如何正确处理?

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 ): 关于X Display,您需要共享xserver套接字( 注意docker不能在exec期间绑定安装volume )并设置$DISPLAY (示例Dockerfile ):

FROM archlinux/base

RUN pacman -Syyu --noconfirm xorg-xeyes

ENTRYPOINT ["xeyes"]

Build the docker image: docker build --rm --network host -t so:57733715 . 构建docker图像: docker build --rm --network host -t so:57733715 .

Run the docker container: docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY so:57733715 运行docker容器: docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY so:57733715

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). 注意 :如果No protocol specified错误,则可以使用xhost +禁用主机检查,但是会出现警告(有关其他信息, 参见man xhost )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM