why can i not run a X11 application?

梦想的初衷 提交于 2019-12-13 11:25:16

问题


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?


回答1:


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"]

Build the docker image: 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

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).



来源:https://stackoverflow.com/questions/57733715/why-can-i-not-run-a-x11-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!