我有一个 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]