无法在Archlinux主机中的docker容器中运行X应用程序

时间:2015-03-02 14:12:28

标签: ubuntu docker x11 archlinux x11-forwarding

我有一个Dockerfile,可以让我运行X应用程序。 它在Ubuntu主机中完美运行,但在Archlinux主机中却不行:

FROM mascip/archlinux:2014.12.09

# To avoid a bug with the filesystem: https://registry.hub.docker.com/u/base/arch/
RUN sed 's/^CheckSpace/#CheckSpace/g' -i /etc/pacman.conf

# BROWSERS
RUN pacman --noconfirm -S nvidia-libgl && pacman --noconfirm -S leafpad

# NON-ROOT USER
# Replace you uid, gid, and username
RUN pacman --noconfirm -S sudo
RUN export uid=1000 gid=1000 && the_user="abla" && \
    the_home="/home/${the_user}" && \
    the_capital_user=$(echo $the_user | sed 's/./\U&/') && \
    mkdir -p $the_home && \
    echo "${the_user}:x:${uid}:${gid}:${the_capital_user},,,:/${the_home}:/bin/bash" >> /etc/passwd && \
    echo "${the_user}:x:${uid}:" >> /etc/group && \
    echo "${the_user} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${the_user} && \
    chmod 0440 /etc/sudoers.d/${the_user} && \
    chown ${the_user}:${the_user} -R ${the_home}

# Replace username and home
ENV USER abla
ENV HOME /home/abla
WORKDIR /home/abla

USER abla

CMD /usr/bin/leafpad

为了运行它,我做:

$ docker build -t a1 .

$  docker run -ti \
    -e DISPLAY -e XAUTHORITY=/tmp/.Xauthority -v /home/user/.Xauthority:/tmp/.Xauthority -v /tmp/.X11-unix:/tmp/.X11-unix \
    a1 leafpad

在Ubuntu中工作(一个Leafpad窗口打开),但不是在我得到的Arch中:

leafpad: Cannot open display:

我需要尽快完成这项工作。任何进一步调查的想法都将受到赞赏。

PS:我有一个类似的Docker容器,它在Ubuntu容器中运行leafpad;这个容器的问题也完全相同。 PPS:Dockerfile来自这里:[url] http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/[/url]

1 个答案:

答案 0 :(得分:0)

尝试使用

xhost +

然后搞乱xauth的东西